Enables you to declare calls to external procedures from an external dynamic-link library (DLL).QTP-extern-object

Syntax –

Extern.Declare(RetType, MethodName, LibName, Alias, [ArgType(s)])

Example –

'Declare FindWindow method

<a name="wp1651065"></a>

Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString

<a name="wp1651066"></a>

'Declare SetWindowText method

<a name="wp1651067"></a>

Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString

<a name="wp1651068"></a>

'Get HWND of the Notepad window

<a name="wp1651069"></a>

hwnd = Extern.FindWindow("Notepad", vbNullString)

<a name="wp1651070"></a>

if hwnd = 0 then

<a name="wp1651071"></a>

MsgBox "Notepad window not found"

<a name="wp1651072"></a>

end if

<a name="wp1651073"></a>

'Change the title of the notepad window

<a name="wp1651074"></a>

res = Extern.SetWindowText(hwnd, "kuku")

Additional Reading

How to load a DLL with QTP?