| || |
accessing Custom Dlls in UFT
I was trying to access custom dlls and methods to make use of object properties in UFT at runtime.
I was able to work with user32.dlls. But, I am not clear how I can make any custom DLL of AUT get exposed it's methods for use by UFT.
In general you can not at least not directly however as most people in HP UFT do
you can make a workbook with VBA modules which can use dll's like user32.dll (search google for examples) and save as power.xlsm\
works at least in excel 2010 and 2013 so I assume also in 2007 this works
You then can call subroutines/functions by doing xlapp.run(<path> & "\power.xlsm"
Excel part and save as power.xlsm
'Make a userform1 with label1
'Make this function in a new VBA module
'Public Function demoScreen(strTxt As String)
' UserForm1.Label1.Caption = strTxt
' UserForm1.Show vbModal
' demoScreen = "finished"
*** And this part you can do from HP UFT ***
Set fso = CreateObject("Scripting.FileSystemObject")
set wbFW = xlApp.workbooks.open(tPath & "\power.XLSM")
result=xlApp.run("demoscreen","hello world of vba")
You can directly declare functions from DLLs that are registered in Windows using Extern.Declare(RetType, MethodName, LibName, Alias, [ArgType(s)]). The important thing here is that the DLL must be registered. You can do that with regsvr32.exe. If your DLL is 64 bit, you'll use %systemroot%\System32\regsvr32.exe. If the DLL is 32 bit, use %systemroot%\SysWoW64\regsvr32.exe.
Tags for this Thread