C# --> C++ Pointer question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • calmlikeabomb
    New Member
    • Mar 2008
    • 1

    C# --> C++ Pointer question

    Hello,

    I am currently trying to interact with a unmanaged DLL (C++). I am attempting to call a method from the DLL that takes a List of unsigned longs and returns a status code.

    Since List is of type General, this can not be marshaled so I am trying to send an Array instead. An issue arises because I need to call this Array later to get data from it and there is no method in the DLL to return this List (Array) to me.

    I am trying to send a pointer of my Array in C# so I can read what is in the Array after the function in C++ inserts data into this Array.

    from my main function
    =============== ===
    myModules = new ArrayList();
    int status = CDLL.GetModuleL ist(myModules);


    from CDLL
    ========
    [DLLImport("myDL L.dll", EntryPoint="Get ModuleList"]
    public static extern int GetModuleList(A rrayList moduleList);


    This does not seem to work (I am not dealing with the pointers right now, I was just trying to call the function correctly).
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Your DLLImport for the DLL function should have the same (or at least comparable) types for things.
    ArrayList is not a valid unmanaged type. You would need to specify a DataType that works for both managed and unmanaged.
    If it's a pointer, try using IntPtr

    Comment

    Working...