CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Apr 2007
    Posts
    7

    c# - passing an array of structs to a native DLL

    Hi all,

    I've been looking for some assistance on this all day with no luck, so any pointers would be helpful.

    struct SID_SEARCH_RESULT_DATA
    {
    ULONG ulFieldID;
    USHORT usFieldLength;
    char szFieldData[FIELD_LENGTH];
    };

    I want to pass this from a c# app into an unmanaged c++ dll and populate it. I've tried a couple of things but with no joy - can anyone give me an idea of the c++ exported method signature and the c# extern method declaration required to pass an array of this struct and populate it?

    The main complication is that I won't know how many results I will have up front, so I need to be able to assign sufficient memory on the c++ dll side.

    Any help would be hugely appreciated.

    Thanks , Lee.

    Edit: The C++ dll is not a COM object or anything similar, just a straight DLL. That's why I want to do this via p/invoke and some sort of marshalling wizardry. As you may be able to tell, this has landed on my desk with an urgent sticker on it and I'm new to c# & .NET, so I just need to get it working.
    Last edited by Azrael_666; April 30th, 2007 at 07:19 AM.

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