Results 1 to 2 of 2

Thread: [RESOLVED] Callback from C++ DLL using fixed length array

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Resolved [RESOLVED] Callback from C++ DLL using fixed length array

    I have an C++ DLL into which I need to register a Callback.
    My problem is that the C++ DLL expects fixed length arrays. How do I need to delcare the arrays in the CallBack and the Function.

    The C++ Type is delcalred as
    Code:
    typedef void (*Full_Callback) (int Site, bool Change(8));
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Callback from C++ DLL using fixed length array

    found the "solution" by myself.
    Instead of the expected fixed array, I delcare a matching Structure that holds all variables.
    for the above Callback in the DLL I use:

    Code:
    Public Structure strucChange
      Public Bool0 As Boolean
      Public Bool1 As Boolean
      Public Bool2 As Boolean
      Public Bool3 As Boolean
      Public Bool4 As Boolean
      Public Bool5 As Boolean
      Public Bool6 As Boolean
      Public Bool7 As Boolean
    End Structure
    <UnmanagedfunctionPointer(CallingConvention.Cdecl)> Public Delegate Sub DelCallback(ByVal Site as Integer, ByRef Change As strucChange)
    <DllImport("MyLib.dll", Entrypoint:="Full_Callback", setlasterror:=True, CharSet:= CharSet.Ansi, exactspelling:=True; CallingConvention:=CallingConvention.Cdecl)>_
    Public Shared Sub FullCallback( ByVal Active As Boolean, ByVal CallbackAddr As DelCallback)
    End Sub
    of course there is also a Sub with the same parameters as in the DelCallback definition.
    Last edited by opus; May 16th, 2013 at 08:44 AM.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

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