For example, the API declaration for Beep is
Public Declare Function Beep Lib "Kernel32″alias" Beep "(ByVal dwfreq as Long, ByVal dwduration as long) as long
Then use the following method
' Create object Set Wrap = CreateObject ("Dynamicwrapper") ' Register Apiwrap.register ' KERNEL32. DLL "," Beep "," I=ll "," F=s "," r=l "' Call Apiwrap.beep (500, 100)
Where the registration API, "I=LL" is the parameter type of the API, "F=s" is the Calling method, "R=l" is the return type
These can be referenced in the following instructions.
REM I: (Argument Type) rem ' a ', sizeof (idispatch*), vt_dispatch}//a idispatch*rem ' C ', sizeof (unsigned char), vt_i4}//C s igned Charrem ' d ', sizeof (double), vt_r8}//D 8 byte realrem ' F ', sizeof (float), vt_r4}//F 4 byte Realrem ' K ', sizeof (Iun known*), vt_unknown}//k Iunknown*rem ' h ', sizeof (long), vt_i4}//H handlerem ' l ', sizeof (long), vt_i4}//l Longrem ' p ', s Izeof (void*), vt_ptr}//P Pointerrem ' s ', sizeof (BSTR), vt_lpstr}//s Stringrem ' t ', sizeof (short), vt_i2}//T Shortrem ' u ', sizeof (UINT), vt_uint}//u unsigned intrem ' W ', sizeof (BSTR), vt_lpwstr}//w wide stringrem F: (call Method) REM ' m '-D C_microsoft 0x0000, Defaultrem ' B '-Dc_borland 0x0001, BORLAND compatrem ' s '-dc_call_std 0x0020, __stdcallrem ' C '-dc_ Call_cdecl 0x0010, __cdeclrem ' 4 '-Dc_retval_math4 0x0100, return value in Strem ' 8 '-Dc_retval_math8 0x0200, return Val UE in Strem R: (Return Type) REM Same as I
Example:
' Use the buzzer in the chassis to play Music sub Beepmusic () Set Wrap = CreateObject ("Dynamicwrapper") Wrap.register "KERNEL32. DLL "," Beep "," I=ll "," F=s "," r=l "res = wrap.beep (+) res = Wrap.beep (550, +) res = Wrap.beep (+) res = wrap.be EP (650, +) res = Wrap.beep (in. 60) Wscript.Sleep 200res = Wrap.beep (.) res = Wrap.beep (650,) res = Wrap.beep 0) res = wrap.beep (550, +) res = Wrap.beep (.) End Subbeepmusic
' Take foreground form title sub Getforewindowcaption () Const wm_gettext = &hdset Wrap = CreateObject ("Dynamicwrapper") Wrap.register " USER32. DLL "," GetForegroundWindow "," F=s "," R=l "Wrap.register" USER32. DLL "," SendMessage "," I=lllr "," F=s "," r=l "Title = Space (+) res = Wrap.sendmessage (Wrap.getforegroundwindow (), wm_ GETTEXT, Max, Title) getforewindowcaption = Titleend Submsgbox getforewindowcaption
send keyboard message, display Desktop sub Showdesktop () const VK_LWIN = &h5bconst Vk_d = &h44public Const keyeventf_keyup = &h2set Wrap = CreateObject ("Dynamicwrapper") Wrap.register "USER32. DLL "," keybd_event "," I=CCLL "," F=s "Wrap.keybd_event vk_lwin, 0, 0, 0wrap.keybd_event vk_d, 0, 0, 0wrap.keybd_event VK_D, 0, Keyeventf_keyup, 0wrap.keybd_event vk_lwin, 0, Keyeventf_keyup, 0End subshowdesktop