如何将自定义DLL添加到QTP中

时间:2013-02-04 12:35:25

标签: dll vbscript qtp pdfbox

如何将自定义DLL添加到QTP中,实际上我需要在DLL文件中存在的vbscript(QTP)中使用某些方法,现在如何在QTP中引用该特定的DLL 是否有可能

任何人都可以帮助我,因为我刚接触QTP

2 个答案:

答案 0 :(得分:1)

您可以使用extern.Declare声明驻留在dll中的外部函数。使用Extern.{name of function}来使用该功能。

查看光标是否显示为沙漏的示例:

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() 

更多用法,您可以随时参考QTP的帮助功能。实际上非常好!

答案 1 :(得分:0)

您可以在vbscript中实现相同的功能,并将此函数库与您的测试相关联......