Forum Discussion

ebernie's avatar
ebernie
New Contributor
13 years ago

Usage of DLL Custum Data Structure (VBS)

The following code generates an Err when a string is affected to the structure field called tTmpParam.sKeyword. May you tell me the correct syntax to use in order to handle this tTmpParam.sKeyword field?


Thank you in advance.


Dim typeParamId2

typeParamId2 = DLL.DefineType("typeParam2",_

                                vt_lpstr, "sKeyword",_  

                                vt_lpstr, "sValue",_

                                vt_i4, "ivalue")


Sub AfficheParam


    '---------------------------------------------------------------------------------------- 

    On Error Resume Next

    '----------------------------------------------------------------------------------------

    Dim tTmpParam, tempstr

    Set tTmpParam = DLL.New("typeParam2")

    Set tempstr = DLL.New("LPSTR",256)

    Set tTmpParam.sKeyword = DLL.New("LPSTR",256)


    tTmpParam.ivalue = 15

    MsgBox Cstr(tTmpParam.ivalue)

    tempstr.Text = "MessageTempStr"

    MsgBox tempstr.Text

    tTmpParam.sKeyword.Text = "MessagesKeyword"

    MsgBox tTmpParam.sKeyword.Text



    MsgBox "Error  : " & Err & Err.Description


End Sub

  • Hello,



    Which TestComplete version are you using (Help > About)?



    Your script works fine for me in TestComplete 9 if I replace

    tTmpParam.sKeyword.Text = "MessagesKeyword"

    MsgBox tTmpParam.sKeyword.Text
    with

    tTmpParam.sKeyword = "MessagesKeyword"

    MsgBox tTmpParam.sKeyword
  • ebernie's avatar
    ebernie
    New Contributor
    Hello,



    I am using TestComplete version 8.60.665.7. The code doesn't work even with the advised corrections. Is there a parameter to configure in the set-up to insure a normal working of DLL functions?
  • Hello,



    To make this work, you'll need to upgrade to TestComplete 8.70 and install a patch for the DLL Access plug-in. To get the patch, please open a support ticket and refer to this forum thread.



    Alternatively, you can upgrade to TestComplete 9, which does not have this issue.