CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    JAPAN
    Posts
    11

    How to pass UDT to a C++ DLL which contains Arrays

    My problem is,

    UDT:


    public Type mwin6_tbl
    kda(69) as string * 84
    KMax as Integer
    kdax as string * 319
    kdl as Integer
    kpl as Integer
    kpl2 as Integer
    kxpc as Integer
    kbnflg as string * 2
    posflg as Integer
    jobflg as Integer
    endflg as Integer
    null as string * 1
    End Type

    public mwin6 as mwin6_tbl

    public const mwin6Size = 5218 '(This value I want to know exactly how many bytes -the above UDT)


    Declare Function msetenv Lib "c:\windows\system\AUTOCALC.DLL" (win6 as Byte) as Integer
    Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" ( lpvDest as Any, lpvSource as Any, byval cbCopy as Long)



    Declare Function msetyouind Lib "c:\windows\system\AUTOCALC.DLL" (ind1 as
    Byte) as Integer

    public sub mysub()

    Ret% = Fmsetyouind()

    End Sub



    public Function Fmsetyouind() as Integer

    Dim mwin6byte() as Byte

    ReDim mwin6byte(mwin6Size) as Byte

    CopyMemory mwin6byte(0), mwin6, mwin6Size
    Ret% = msetyouind(mwin6byte(0))
    CopyMemory mwin6, mwin6byte(0), mwin6Size

    If Ret% = 0 then ER% = 1: GoTo ERMSG1
    Fmsetyouind = 1

    ERMSG1:
    Exit Function

    End Function






    But my code is giving error. VB is geting crashed soon after accessing the DLL.

    Can you please help me out how to solve my problem, I am already crossed my deadline of the project.



    Ramaswamy

  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: How to pass UDT to a C++ DLL which contains Arrays

    Using the LenB command in VB gives 12420 bytes i.e.:


    private Type mwin6_tbl
    kda(69) as string * 84
    KMax as Integer
    kdax as string * 319
    kdl as Integer
    kpl as Integer
    kpl2 as Integer
    kxpc as Integer
    kbnflg as string * 2
    posflg as Integer
    jobflg as Integer
    endflg as Integer
    null as string * 1
    End Type

    private Sub Form_Load()

    Dim x as mwin6_tbl

    Debug.print LenB(x) & " bytes "

    End Sub





    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured