Jump to content
Sign in to follow this  
FaT3oYCG

[SOLVED] DLLCall dword not working? [[ DLLCall BOOL type?

Recommended Posts

FaT3oYCG

Hi havent been arround here for a while but i have recently decided to pick autoit up again, i have decided to work on writing a bluetooth library.

the problem that i have come accross is not finding the documentation, api calls and function references for my bluetooth dll but with the DLLCall function of autoit, i have looked at the documentation and the function i would like to use in the dll is a boolean return value but searching the documentation that is not documented to be a return type of the DLLCall function, can anyone help me out on that one.

Thanks.

Edited by FaT3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Share this post


Link to post
Share on other sites
Yashied
FaT3oYCG

thanks, ok now i have a problem with sending a parameter to a nother function

the function in the dll takes this formt according to the API

BOOL function_name(DWORD dword_value)

and the dword_value seems to take the form of a number i.e. a time in seconds

ok so i have used

$result = DLLCall($dll, "int", "function_name", "dword", "1")

$result = DLLCall($dll, "int", "function_name", "dword", 1)

$result = DLLCall($dll, "int", "function_name", "int", "1")

$result = DLLCall($dll, "int", "function_name", "int", 1)

yet autoit just crashes and gives error number -1073741819


Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Share this post


Link to post
Share on other sites
SmOke_N

thanks, ok now i have a problem with sending a parameter to a nother function

the function in the dll takes this formt according to the API

BOOL function_name(DWORD dword_value)

and the dword_value seems to take the form of a number i.e. a time in seconds

ok so i have used

$result = DLLCall($dll, "int", "function_name", "dword", "1")

$result = DLLCall($dll, "int", "function_name", "dword", 1)

$result = DLLCall($dll, "int", "function_name", "int", "1")

$result = DLLCall($dll, "int", "function_name", "int", 1)

yet autoit just crashes and gives error number -1073741819

How was the DLL compiled?

Have you tried:

$a_result = DLLCall($dll, "int:cdecl", "function_name", "dword", 1)
MsgBox(64, "Bool Return", $a_result[0])
?

Edit:

Also remember that the 3rd parameter is case sensitive.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
FaT3oYCG

thanks a load the cdecl was the problem, i dont realy know what that does but im guessing it has something to do with a C type declaration but yeah i know the third param is case sensitive but thanks for the advice now i can get to work making my bluetooth script thanks.


Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Share this post


Link to post
Share on other sites
martin

thanks, ok now i have a problem with sending a parameter to a nother function

the function in the dll takes this formt according to the API

BOOL function_name(DWORD dword_value)

and the dword_value seems to take the form of a number i.e. a time in seconds

ok so i have used

$result = DLLCall($dll, "int", "function_name", "dword", "1")

$result = DLLCall($dll, "int", "function_name", "dword", 1)

$result = DLLCall($dll, "int", "function_name", "int", "1")

$result = DLLCall($dll, "int", "function_name", "int", 1)

yet autoit just crashes and gives error number -1073741819

I think that in C a boolean type can be the equivalent of "ubyte" in AutoIt so it is worth trying that. It's difficult to be sure because C doesn't actually have a boolean type and the author could have used a char type or int as a return value.

If the value passed should be a dword then don't use a string.

Also, are you certain the function is really called function_name? (or are you just using that for the example?)

Try

$result = DLLCall($dll, "int", "function_name", "dword", 0x00000001);but I think just 1 should work
 
;OR
 $result = DLLCall($dll, "ubyte", "function_name", "dword", 0x00000001)

You might need to use the cdecl calling method, it depends how the dll was written

$result = DLLCall($dll, "int:cdecl",  "function_name", "dword", 0x00000001)
;and also try
 $result = DLLCall($dll, "ubyte:cdecl",  "function_name", "dword", 0x00000001)

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
monoceres

thanks a load the cdecl was the problem, i dont realy know what that does but im guessing it has something to do with a C type declaration but yeah i know the third param is case sensitive but thanks for the advice now i can get to work making my bluetooth script thanks.

cdecl is a calling convention. It's a set of rules that determines how the interpreter/compiler should push the parameters on to the stack. If you use the wrong one the stack will be corrupted and after that it's game over.

I think that in C a boolean type can be the equivalent of "ubyte" in AutoIt so it is worth trying that. It's difficult to be sure because C doesn't actually have a boolean type and the author could have used a char type or int as a return value.

Just to clarify, in WINAPI ( written in C ) a BOOL is just a typedef for int. In C++ type called bool which is indeed one byte (as you said ubyte would be a good replacement in autoit). However I haven't seen the usage of a bool anywhere when using dll's (due to the fact that most libraries implemented as dll's are written in C).

Edit: After reading martin's post again I changed my wordings.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.