Micro Focus QTP (UFT) Forums
VBS to DLL to QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: VBS to DLL to QTP (/Thread-VBS-to-DLL-to-QTP)



VBS to DLL to QTP - ssco77 - 04-07-2010

Could you please guide me on how to create DLL from a VBS file. And how such a DLL is associated to test so that I can call the functions in VBS.

Regards.


RE: VBS to DLL to QTP - jsknight1969 - 04-07-2010

Sorry you can't do it that way. You can create Classes in VBS then call the class.function, but they do not compile into DLLs. You need to use Visual Studio 6 or .NET to create dlls then install them as COM components in order to consume them in VBS/QTP. VS.NET does it pretty easily by selecting "Make Assembly COM visible" then registering. There are plenty of Google examples how to do this. You can even use the free Express editions of Visual studio to create and compile the dll files.

Easiest thing to do for QTP is create a VBS file then associate the file with your test/action in settings. You can still use classes.

Code:
'create class
Class TestMe
public sub HelloWorld()
   msgbox "Hello there"
end sub
End Class

'instantiate and consume
dim cltest: set cltest = New TestMe
cltest.HelloWorld

If you still wish to use DLLs then here is how. Create/compile dll using Visual studio. Register as COM component (Resasm.exe, I think...it's part of .NET utilities). Now QTP:
Code:
'if you use a namespace, don't forget to include it namspace.class
dim cltest:set cltest = CreateObject("cltestdll")
cltest.HelloWorld


I hope this helps.


RE: VBS to DLL to QTP - shirkaan - 01-28-2011

i have created one dll in C++ in visual studio 2005 for some functionality. I have to use /link it in QTP scripts. How can i do this???

Shall i need to convert it to COM component and install them????


RE: VBS to DLL to QTP - cdesserich - 01-30-2011

You can create COM components in VBScript with Windows Scripting Components. It's just a little extra XML. Check them out: http://msdn.microsoft.com/en-us/library/07zhfkh8%28v=vs.85%29.aspx


RE: VBS to DLL to QTP - jsknight1969 - 02-16-2011

You need to register the dll in the Global Assembly.

c:\windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe your.dll /codebase

Then you can consume it via VBscript.



RE: VBS to DLL to QTP - prashants1 - 12-16-2011


we have created two scripts in vbscript for the ‘remote agent’ and ‘viewscript’. However, we need to place the dll/exe files in QC for custom test types. We are working on the conversion of these vbscript files to dll/exe. Is there any straight way to convert these in DLL or exe for QC 11.0