You can also give Gilles Laurent DynaWrap ocx a chance.
This type of dll must be registered on the target system, for example regsvr32 /s DynaWrap.dll
.
It is limited to 32-bit DLLs, and it may not be convenient for you to use, but it works on 64-bit Windows. You cannot access a function exported by serial number, and you cannot directly process 64 bits or more values ββ/ pointers.
Here is a sample for calling MessageBoxA
from JScript:
var oDynaWrap = new ActiveXObject( "DynamicWrapper" )
And here from VBScript:
Option Explicit Dim oDynaWrap Set oDynaWrap = CreateObject( "DynamicWrapper" ) ' to call MessageBoxA(), first register the API function UserWrap.Register "USER32.DLL", "MessageBoxA", "I=HsSu", "f=s", "R=l" ' now call the function UserWrap.MessageBoxA Null, "MessageBoxA()", "A messagebox from VBScript...", 3
To use a function, you need to "register" the exported function of your DLL. To do this, you need to call the register method with the first parameter containing the string object, the full path to the DLL, the second parameter for the exported name of the function used and the following three parameters that describe the declaration of the functions in some way hidden syntax.
i=
describes the number and data type of function parameters.
f=
describes the type of call: _stdcall
or _cdecl
. The default is _stdcall
.
r=
describes the data type of the return value.
Supported data types:
Code Variant Description a VT_DISPATCH IDispatch* b VT_BOOL BOOL c VT_I4 unsigned char d VT_R8 8 byte real f VT_R4 4 byte real h VT_I4 HANDLE k VT_UNKNOWN IUnknown* l VT_I4 LONG p VT_PTR pointer r VT_LPSTR string by reference s VT_LPSTR string t VT_I2 SHORT u VT_UINT UINT w VT_LPWSTR wide string
Thus, the call to the Register
method used in the examples describes MessageBoxA
as follows:
_stdcall LONG MessageBoxA( HANDLE, LPSTR, LPSTR, UINT );
For an explanation of MessageBoxA, see the docs on MSDN .
Read the DynaWrap docs for more complex examples ... But you may need to translate Google because they are written in French; -)