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

    Passing Array of structures to a DLL

    1. How to pass an array of structures to a DLL and retrieve back the values ?

    2. How to type cast a user-defined type in VB ?


    BRR

  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Passing Array of structures to a DLL

    1. Define the Function with "As Any"

    Declare Function SomeDllFunc lib "SomeDll"( byref lpUdtAr as Any, byval nc as long) as long



    Then call the function by passing the first element

    dim pUdt(9) as UDTSTRUCT
    lrtn = SomeDllFunc(pUDT(0),10) ' typically the second param telling how many valid elements in the array



    2. Type Casting is to be implemented by making another copy actually. You can search the articles secttion to see how exactly it is done.
    I presume you are refering to Function which return a pointer to a type..

    Declare Function UdtReturningFunc Lib "Something" () as long
    ' get the declaration for RtlMoveMemory ( more famous as CopyMemory fn) . i dont remember off-hand.. something like..
    Declare Sub CopyMemory lib "Kernel32" Alias "RtlMoveMemory" (lpDest as Any, lpSource as Any, lBytes as Long)

    dim pUdt as SOmeUdt
    dim lpudt as long
    lpUdt = UdtReturningFunc ()
    CopyMemory pUdt, byval lpUdt, len(pUdt)
    ' This is actually another copy of the data.. not
    ' not all that efficient as a Typecast




    RK

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