Forum Discussion

neha_sharma's avatar
neha_sharma
Contributor
12 years ago

Calling DLL from testcomplete

Hi,



i am using TestComplete 10 and need to call DLL routine from my script unit.



DLL function is :




Public Class MyFunctions



Public Function AddMyValues(ByVal Value1 As Integer, ByVal Value2 As Integer)



3:



Dim Result As Integer



4:



5:



Result = Value1 + Value2



6:



7: Return Result



8:



9:



End Function



End Class




TestComplete code is :


Function CallDLLRoutine()



' Defines the dll types



Set Def_DLL1 = DLL.DefineDLL("ClassLibrary1")



Call Def_DLL1.DefineProc("AddMyValues",vt_i4,vt_i4,vt_i4)



Call Def_DLL1.DefineAlias("AddMyValuesOne", "AddMyValues")



Set Lib1 = DLL.Load("C:\TestComplete\ClassLibrary1.dll")



 



result = Lib1.AddMyValuesOne(2,2)



 



End Function



I am getting an error :




 



Object doesn't support this property or method: 'Lib1.AddMyValuesOne'

Error location:

Unit: "GmailKeywordTest\GmailKeywordTest\Script\Unit1"

Line: 12 Column: 5.





I dont know what is wrong with the code.Followed all steps mentioned in TestComplete help.

Any suggestions.



Thanks,

Neha

2 Replies

  • Hi,



    Does anyone have the idea of how to use DLL with TC.I have already mentioned the code i have writen ,but its not working.

    Also contacted smartbear support.

    Case#00034982



    -Neha
  • Hi,



    I have used another way to access DLL now.

    Treat DLL as an ole object and use it in scripts.

    But we have to register the DLL before using in HKEY_CURRENT_ROOT.


     


    C:\windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\TestComplete\Utilities\ClassLibrary1.dll" /tlb

     

    Set Rep = sys.oleObject("ClassLibrary1.MyFunctions")

    num = Rep.AddMYVAlues(2,2)



    Thanks,

    Neha