Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: COM Object for DLL Calls DllCall
Reference:http://www.ddj.com/windows/210200078
DynaWrap: https://techsupt.winbatch.com/techsupt/dynawrapNt.zip
;========================================================================================================================================== ; ; How to use DynaWrap "dynwrap.dll" in WinBatch scripts. ; ;========================================================================================================================================== ; Following examples demonstrate how to use the "dynwrap.dll" for accessing API functions from WinBatch script. ; ; The examples need to have the ActiveX "dynwrap.dll" installed and registered as a COM server. ; ; The "dynwrap.dll" is part of the zip package "dynawrapNt.zip". ; Download from there: http://freenet-homepage.de/gborn/WSHBazaar/WSHDynaCall.htm ; ; See also: A DynaCall() Function for Win32, http://www.ddj.com/dept/windows/184416502 ; See also: An Automation Object for Dynamic DLL Calls, http://www.ddj.com/dept/windows/210200078 ; ; Copy the "dynwrap.dll" to a folder of your wish and register it in the system. ; To register "dynwrap.dll", type at the commandline prompt: "regsvr32.exe dynwrap.dll" ; ; This script programmatically registers the DynamicWrapper DLL file, which is assumed to reside in the same folder as this script. ; Un-registering is not provided by the DLL, but programmtically realized within this script by removing the specific registry keys. ; ; (c)Detlev Dalitz.20100124.20100125. ;========================================================================================================================================== ; Register DynaWrap. intResult = DllCall (DirScript () : "DYNWRAP.DLL", long : "DllRegisterServer") Message ("DynamicWrapper", "DynamicWrapper is registered.") ; Create DynaWrap object. objDW = ObjectCreate ("DynamicWrapper") ; Example 1. objDW.Register("USER32.DLL", "MessageBoxA", "f=s", "i=hssu", "r=l") objDW.Register("USER32.DLL", "MessageBoxW", "f=s", "i=hwwu", "r=l") intResult1 = objDW.MessageBoxA(ObjectType("NULL"), "MessageBox (ANSI)", "From DynaWrap Object 1", 3) ; 6 = Yes. intResult2 = objDW.MessageBoxA(ObjectType("NULL"), "MessageBox (ANSI)", "From DynaWrap Object 2", 3 | 256) ; 7 = No. intResult3 = objDW.MessageBoxW(ObjectType("NULL"), "MessageBox (UNICODE)", "From DynaWrap Object 3", 3 | 512) ; 2 = Cancel. ; Example 2. Decimals (6) objDW.Register("MSVCRT.DLL", "sin", "f=mc8", "i=d", "r=d") objDW.Register("MSVCRT.DLL", "cos", "f=mc8", "i=d", "r=d") objDW.Register("MSVCRT.DLL", "sinh", "f=mc8", "i=d", "r=d") objDW.Register("MSVCRT.DLL", "cosh", "f=mc8", "i=d", "r=d") fltResult1 = objDW.Sin(@PI / 2.0) ; 1.000000 intResult1 = objDW.MessageBoxA(DllHwnd(""), : "Sin (@PI / 2.0) = " : fltResult1, "MSVCRT|Sin", 1) fltResult2 = objDW.SinH(@PI / 2.0) ; 2.301299 intResult2 = objDW.MessageBoxA(DllHwnd(""), : "SinH (@PI / 2.0) = " : fltResult2, "MSVCRT|SinH", 1) fltResult3 = objDW.Cos(@PI / 2.0) ; 0.000000 intResult3 = objDW.MessageBoxA(DllHwnd(""), : "Cos (@PI / 2.0) = " : fltResult3, "MSVCRT|Cos", 1) fltResult4 = objDW.CosH(@PI / 2.0) ; 2.509178 intResult4 = objDW.MessageBoxA(DllHwnd(""), : "CosH (@PI / 2.0) = " : fltResult4, "MSVCRT|CosH", 1) ;Example 2. objDW.Register("KERNEL32.DLL", "GetPrivateProfileString", "f=s", "i=ssslls", "r=l") ; DWORD WINAPI GetPrivateProfileString( ; __in LPCTSTR lpAppName, ; __in LPCTSTR lpKeyName, ; __in LPCTSTR lpDefault, ; __out LPTSTR lpReturnedString, ; __in DWORD nSize, ; __in LPCTSTR lpFileName ; ); strIniFilename = DirHome () : "WIL.CLR" strIniSection = "COLORS" strIniKey = "CON" intBBSize = 2048 hdlBB = BinaryAlloc (intBBSize) BinaryEodSet (hdlBB, intBBSize) intBBAddr = BinaryBufInfo (hdlBB, 1) intSize = objDW.GetPrivateProfileString(strIniSection, strIniKey, "", intBBAddr, intBBSize, strIniFilename) strIniValue = BinaryPeekStr (hdlBB, 0, intSize) ; e. g. "128,0,128" hdlBB = BinaryFree (hdlBB) intResult = objDW.MessageBoxA(DllHwnd(""), : strIniFilename : @LF : @LF : strIniSection : "=" : strIniValue, "GetPrivateProfileString", 0 | 64) Drop (objDW) :@CANCEL ; Un-register DynaWrap. blnResult = @FALSE If RegExistKey (@REGMACHINE, "SOFTWARE\Classes\DynamicWrapper\CLSID") strCLSID = RegQueryValue (@REGMACHINE, "SOFTWARE\Classes\DynamicWrapper\CLSID[]") If strCLSID != "" If RegExistKey (@REGMACHINE, "SOFTWARE\Classes\CLSID\" : strCLSID : "\InProcServer32") strFilePath = RegQueryValue (@REGMACHINE, "SOFTWARE\Classes\CLSID\" : strCLSID : "\InProcServer32[]") If FileExist (strFilePath) == 1 blnResult = RegDeleteKey (@REGMACHINE, "SOFTWARE\Classes\CLSID\" : strCLSID) If blnResult Then blnResult = RegDeleteKey (@REGMACHINE, "SOFTWARE\Classes\DynamicWrapper") Else Message ("DynamicWrapper", "DynamicWrapper cannot un-register." : @LF : "DLL file not found at registered file path." : @LF : strFilePath) EndIf EndIf EndIf EndIf If blnResult Then Message ("DynamicWrapper", "DynamicWrapper is un-registered.") Exit
Article ID: W18170
Filename: COM Object for DLL Calls .txt
File Created: 2019:08:14:09:27:30
Last Updated: 2019:08:14:09:27:30