Jump to content

DllCall - CallBack


Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...