Register Method
This method registers a function exported by a DLL as an object method. The function is identified by its name or ordinal. The meaning of "i=", "r=" and "f=" is explained in the remarks.Registration by name
DWX = new ActiveXObject("DynamicWrapperX");
DWX.Register("user32.dll", "MessageBoxW", "i=hwwu", "r=l");
res = DWX.MessageBoxW(0, "Hello, world!", "Test", 4); // Call.
Registration under a different name
DWX.Register("user32:BadName", "GoodName", "r=n", "f=t"); // BadName might be a function name that contains characters // not allowed in method names, or simply is too long.Registration by ordinal
DWX.Register("user32:110", "MethodName", "i=p", "r=l"); DWX.Register("user32:0x6E", "MethodName", "i=p", "r=l");Remarks
- If the library's file has a ".dll" extension, the extension is optional. If the file has no extension, you should put a dot after its name. For example, "mylib."
- System DLLs will be found without a path. With others it depends on their location.
- Windows API functions that have string parameters or return values often exist in two variants. For example, MessageBoxW for Unicode strings and MessageBoxA for ANSI. The "A" can be omitted from the name because DWX will add it automatically if it fails to find MessageBox. The "W" can't be omitted.
- The ordinal can be decimal or hexadecimal. Remember that ordinals are not guaranteed to be the same across different versions of a DLL and between the x86 and x64 variants of the same version.
- The arguments marked with the prefixes "i=", "r=" and "f=" may or may not be present, depending on the function, and their order is arbitrary because they are distinguished by the prefixes.
- The letters after "i=" define the types of the function's parameters (integer, floating point number, string, etc). You can see which is what here. The "i=" argument can be omitted only if the function has no parameters by design.
- "r=" specifies the type of the return value. It can be omitted regardless of whether or not the function returns anything.
- The flag parameter "f=" specifies a list of flags that will affect the way the function is called. Currently two flags are recognized: "t" meaning the function's calling convention is "thiscall", and "l" (last error) meaning the GetLastError API must be called immediately after the call of the registered function. You can see the error code it returns with the LastError method. The "t" flag is only used by the 32-bit version of DWX and is ignored by the 64-bit one.