【问题标题】:How to add a custom DLL into QTP如何将自定义 DLL 添加到 QTP
【发布时间】:2013-02-04 23:24:02
【问题描述】:

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

自从我刚接触 QTP 以来,任何人都可以帮助我

【问题讨论】:

    标签: dll vbscript qtp pdfbox


    【解决方案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的帮助功能。其实还不错!

    【讨论】:

    • 上面的示例是针对 user32.dll 但如何调用任何其他自定义 dll 说包含 func 日志的 .net dll?有人可以详细说明吗? dll存放在哪里或者加载到内存中怎么办?
    • @rahoolm,我建议为此创建一个新问题。您是否使用 regsrv32.exe 注册了 .dll?当您使用 .net dll 时,请考虑使用 QTP 中的 dotnetfactory 对象与它们进行交互。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 2011-03-27
      相关资源
      最近更新 更多