问自己今天是否比明天进步了 !

调用外部的dll方法 !

上一篇 / 下一篇  2011-10-24 11:25:49 / 个人分类:QTP学习

1.Extern  

Extern.declear rettype ,"methodname", "libaryname" , "aliasname ", argtype, argtype     


retype:  Type of return value   ;  

aliasname : alias name is not  obligatory  , if you  substitue "" for  the value of  alias ,qtp will take   the function name  as  alias name  !   


argtype  : parameter type   
  

 Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString'声明 FindWindow 方法
Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, MicString'声明 SetWindowText 方法
hwnd = Extern.FindWindow( "Notepad","新建 文本文档 (4).txt - 记事本")'获取记事本窗口的 HWND
if hwnd = 0 then
MsgBox "找不到指定窗口"
else
msgbox   hwnd
res = Extern.SetWindowText(hwnd, "Set Title") '在此也可看出SetWindowText的用法了  '更改记事本窗口的标题

end if

TAG:

 

评分:0

我来说两句

Open Toolbar