C# IntPtr to struct, how to access struct data?

I have a C# function that calls a C++ DLL function. I used the PInvoke wizard found here to generate the code:

http://blogs.msdn.com/vbteam/archive/2008/03/14/making-pinvoke-easy.aspx

The function returns an IntPtr to a Struct. Assuming the marshaling is already done correctly, how can I use the IntPtr to access the fields of the struct?
LVL 4
Fippy_DarkpawAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
grayeConnect With a Mentor Commented:
Here is an example of the casting of a IntPtr to a Structure:
TempNet = (NETRESOURCE) Marshal.PtrToStructure(iPtr, typeof(NETRESOURCE));
0
 
williamcampbellCommented:
You have to map the C++ struct 'structure' to a C# equivalent class.

struct  st  ==>     public class st
{                          {
   int x;                      int32 x;
}                          }


then cast the IntPtr


0
 
softbeeCommented:
Also, take note of the packing of the original
0
All Courses

From novice to tech pro — start learning today.