Jump to content

Recommended Posts

Posted

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?

Posted

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??

Posted (edited)

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

Posted

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

Posted

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

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
×
×
  • Create New...