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

Wednesday, June 10, 2009

How to Access Windows API through vbs?

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.


Navigate to below URL to know how to use the DLL methods.


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"
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.


1 comment :

  1. 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,