G
Guest
How do I get a pointer to an integer into an IntPtr in a structure? I have a
native structure like this:
typedef struct {
DCM_ELEMENT e;
long flag;
long *flagAddress;
} DCM_FLAGGED_ELEMENT;
Going into the native function:
CONDITION
DCM_ParseObject(DCM_OBJECT ** callerObject, DCM_ELEMENT * vector,
int count, DCM_FLAGGED_ELEMENT * flaggedVector, int flagCount,
int *parseCount)
This is what I have in C# so far:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct DCM_FLAGGED_ELEMENT
{
DCM_ELEMENT e;
int flag;
IntPtr flagAddress;
public DCM_FLAGGED_ELEMENT(DCM_ELEMENT elem, int fl, IntPtr pfl)
{
e = elem;
flag = fl;
flagAddress = pfl;
}
}
and the C# function prototype is:
[DllImport("DICOM_Lib.dll", CharSet = CharSet.Ansi)]
public static extern UInt32 DCM_ParseObject(
ref IntPtr callerObject,
[MarshalAs(UnmanagedType.LPArray)]
DCM_ELEMENT[] requiredVector,
int count,
[MarshalAs(UnmanagedType.LPArray)]
DCM_FLAGGED_ELEMENT[] optionalVector,
int flagCount,
IntPtr parseCount);
But how do i actually get the address of an integer into the IntPtr
flagAddress?
Thanks,
Carl
native structure like this:
typedef struct {
DCM_ELEMENT e;
long flag;
long *flagAddress;
} DCM_FLAGGED_ELEMENT;
Going into the native function:
CONDITION
DCM_ParseObject(DCM_OBJECT ** callerObject, DCM_ELEMENT * vector,
int count, DCM_FLAGGED_ELEMENT * flaggedVector, int flagCount,
int *parseCount)
This is what I have in C# so far:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct DCM_FLAGGED_ELEMENT
{
DCM_ELEMENT e;
int flag;
IntPtr flagAddress;
public DCM_FLAGGED_ELEMENT(DCM_ELEMENT elem, int fl, IntPtr pfl)
{
e = elem;
flag = fl;
flagAddress = pfl;
}
}
and the C# function prototype is:
[DllImport("DICOM_Lib.dll", CharSet = CharSet.Ansi)]
public static extern UInt32 DCM_ParseObject(
ref IntPtr callerObject,
[MarshalAs(UnmanagedType.LPArray)]
DCM_ELEMENT[] requiredVector,
int count,
[MarshalAs(UnmanagedType.LPArray)]
DCM_FLAGGED_ELEMENT[] optionalVector,
int flagCount,
IntPtr parseCount);
But how do i actually get the address of an integer into the IntPtr
flagAddress?
Thanks,
Carl