QTP擁有自己的.NET Factory接口,以調用.NET生成的DLL,也可以使用Extern.Declare來進行外部的DLL的訪問。
語法:
Extern.Declare(RetType, MethodName, LibName, Alias [, ArgType(s)])
參數說明:
RetType: 方法返回值的類型。
MethodName:調用DLL文件中的某個方法的方法名。
LibName: DLL文件名。
Alias: 別名,當別名爲空時,方法名和別名一樣(此參數通常爲空)。
ArgType(s): 傳入的參數。
例子:
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString '後面兩個micString爲函數FindWindow函數的參數 Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString |