Ganeshja
Ganeshja

Reputation: 2765

How to add a custom DLL into QTP

How to add a custom DLL into QTP , Actually I need certain methods to be used in vbscript (QTP) present in a DLL file , now how to refer to that particular DLL in QTP is it possible

Can anyone help me out since m new to QTP

Upvotes: 0

Views: 3397

Answers (2)

AutomatedChaos
AutomatedChaos

Reputation: 7500

You can use extern.Declare to declare an external function that resides in a dll. Use Extern.{name of function} to use that function.

Example to see if the cursor is displayed as an hour glass:

extern.Declare micLong,"GetForegroundWindow","user32.dll","GetForegroundWindow" 
extern.Declare micLong,"AttachThreadInput","user32.dll","AttachThreadInput",micLong,
micLong,micLong 
extern.Declare micLong,"GetWindowThreadProcessId","user32.dll",
"GetWindowThreadProcessId",micLong,micLong 
extern.Declare micLong,"GetCurrentThreadId","kernel32.dll","GetCurrentThreadId" 
extern.Declare micLong,"GetCursor","user32.dll","GetCursor" 

function get_cursor() 
    hwnd = extern.GetForegroundWindow() 
    pid = extern.GetWindowThreadProcessId(hWnd, NULL) 
    thread_id=extern.GetCurrentThreadId() 
    extern.AttachThreadInput pid,thread_id,True 
    get_cursor=extern.GetCursor() 
    extern.AttachThreadInput pid,thread_id,False 
end function 

Msgbox get_cursor() 

For more usages, you can always refer to the help function of QTP. It is actually quite good!

Upvotes: 1

user2017677
user2017677

Reputation: 1

You can same implement in vbscript and associate this function library with your tests...

Upvotes: 0

Related Questions