Jump to content
Sign in to follow this  
MadaraUchiha

DllCall - CallBack

Recommended Posts

MadaraUchiha

Hi,

I am currently learning how to use DLLCalls etc.

So I made my first script, using the help files instructions etc:

Local $dwFreq = 600
Local $dwDuration = 1500
Local $DLL_BEEP = DllCall("kernel32.dll","BOOLEAN","Beep",'UINT',$dwFreq,'UINT',$dwDuration)

This works perfectly fine, but I checked PInvoke and MSDN, and it says it has a return type (Boolean in this case)

How can I get the return type, if it succeeded or not, and if not, why? Using GetLastError or something similar?


Share this post


Link to post
Share on other sites
MadaraUchiha

And also...

If I try it like this:

Func SYS_BEEP($dwFreq,$dwDuration)
    Global $BEEP_Return = DllCall("kernel32.dll","BOOLEAN","Beep",'UINT',$dwFreq,'UINT',$dwDuration)
EndFunc

SYS_BEEP(343,500)

MsgBox(0,'Result','DllCall Result was:  ' & $BEEP_Return[0])

It returns me 1 (true?); - even if I set garbage as parameters like letters instead of numbers for the duration.

It still returns 1??


Share this post


Link to post
Share on other sites
kylomas

MU,

Run it like this and look at DLLCALL in the Help file...

#include <array.au3>

Local $dwFreq = 600
Local $dwDuration = 1500
Local $DLL_BEEP = DllCall("kernel32.dll","BOOLEAN","Beep",'UINT',$dwFreq,'UINT',$dwDuration)

_arraydisplay($DLL_BEEP)

kylomas

edit: Feed the call garbage and look at the parms when the callreturns

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
MadaraUchiha

If i change for example the durations param to some garbage, it returns 0 for duration, but main result, $Result[0] is still 1?


Share this post


Link to post
Share on other sites
kylomas

Yes, I see what you mean.  Tried feeding it

-1

string($dwFreq) with $dwFreq = 'a'

chr($dwFreq)

and none of that makes the function fail...?

Maybe someone else has an idea...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
MadaraUchiha

Hm, okay, the problem is still unsolved...


Share this post


Link to post
Share on other sites
trancexx

There are no problems here.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
kylomas

trancexx,

Are you saying that DLLCALL concerts whatever you feed it into a dWord, consequently the call never fails (keeping in mind that 0 is a valid value)?


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
trancexx

If that word is "converts" then yes. Whatever you pass as argument is converted to specified type before the actual call happens.


♡♡♡

.

eMyvnE

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  

×