Forum Discussion

jreutter's avatar
jreutter
New Contributor
12 years ago

DLL interface handling TC6 vs. TC9

Currently we use TC6 and we evaluate if we upgrade to TC9.

(TC6.51.405.5 <-> TC9.20.2460.7 Trial version)

My environment is still the same.

In TC6 following code works:



sub test


  (dim all var)



  G_sAssistBasePath = "C:\Program Files\Motion Suite\CntStudio\"



  Set Def_DLL = DLL.DefineDLL("AssistBase")

  Set Lib = DLL.Load(G_sAssistBasePath + "AssistBase.dll")

  Def_DLL.DefineProc "ExecuteCmdLine", vt_lpstr, vt_lpstr, vt_int

  Def_DLL.DefineProc "GetErrorLine", vt_int, vt_lpstr, vt_int

  Set LpRet = DLL.New("LPWSTR", 1024)

  Set LpCmd = DLL.New("LPWSTR", 1024)

  LpCmd.Text = "NewAssist"

 

  bRet = Lib.ExecuteCmdLine(LpCmd, LpRet) 

end sub



TC9 creates an exception during "Lib.ExecuteCmdLine(LpCmd, LpRet) "

--> An exception occurred: 0xC0000005; class: ; description: ''



Is there a change? Do I need to change something?

Thanks



  • Hi JayR,


     


    TestComplete requires that the exported functions match the stdcall calling convention, you can see this requirement in the Calling DLL Functions From Tests - Known Limitations help topic.


     


    Explicitly specifying the calling convention solves the problem:


     


    ASSIST_EXT_CLASS INT _stdcall ExecuteCmdLine( LPCTSTR lpCommand, LPTSTR lpOutput)


     


    The strange thing is that this limitation was always there, so I am not sure why it worked in version 6.51. However, explicitly setting the convention should not harm TC 6.51 tests anyway.