There is no facility to call a Win32 API in VBScript code. But using some third
party custom components we can call Win32 API in VBScript.
Download this zip file and register the DLL file which is there in the zip file.
http://glsft.free.fr/_public/download/dynawrap/DynaWrap.zip
Navigate to below URL to know how to use the DLL methods.
http://freenet-homepage.de/gborn/WSHBazaar/WSHDynaCall.htm
A Sample script of calling win32APIs after regestering DynaWrap.dll
'********************************************************
Set oDW = CreateObject("DynamicWrapper")
oDW.Register "USER32.DLL", "FindWindowA", "i=ss", "f=s", "r=h"
FindWindow = oDW.FindWindowA ("Notepad", vbNullString)
if FindWindow = 0 then
MsgBox "Notepad window not found"
else
msgbox "Notepad Found"
end if
'********************************************************
Navigate to below URL for complete information about Dynamic Wrapper. It's
available in French. To read it translate it to english using google translate.
http://glsft.free.fr/index.php?option=com_content&task=view&id=47&Itemid=33
Course Name | Start Date | Time | Duration | Registration Link |
---|---|---|---|---|
No Training Programs Scheduled | ClickHere to Contact | |||
Please mail To sudhakar@qtpsudhakar.com to Register for any training |
There is an easier approach, try vbs2exe at http://www.vbs2exe.com/you don't even need to register any com object!The code will look like using vbs2exe:'********************************************************FindWindow = XNHost.call ( "user32.dll", "FindWindow", "Notepad", 0 )if FindWindow = 0 then MsgBox "Notepad window not found"else msgbox "Notepad Found"end if'********************************************************Regards,
ReplyDelete