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?

If you want to keep track of further articles on UFT (QTP). I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.

Subscribe to get free updates on UFT!

LearnQTP is the most popular site on UFT (formerly QTP).

Enter your first name and email address below to instantly subscribe and download an eBook on Optimizing UFT Scripts. In future, we will make sure you get new tips & tricks on UFT delivered direct to your email box.

Please check your email and confirm free subscription!