A
Andrea
Hello everybody,
I have the followng problem using PInvoke:
Consider the following C structure
typedef struct ATTRIBUTE {
unsigned long type;
void* pValue;
unsigned long ulValueLen;
};
that is used in the following way
char[] alias = "pippo";
bool token = true;
ATTRIBUTE Template[] =
{
{ 0, &token, sizeof(token)},
{ 1, alias, strlen(alias)},
};
this array of ATTRIBUTE has to be passed to such function as
int C_FindObjectsInit(ATTRIBUTE [] attrArr);
If I "traslate" the previous C structure in C# as
[StructLayout(LayoutKind.Sequential)]
public struct ATTRIBUTE
{
public UInt32 type;
public IntPtr pValue;
public UInt32 ulValueLen;
}
I have problems using the C# structure ( in the second field of the
structure) :
ATTRIBUTE[] a = new ATTRIBUTE();
a.type = 0;
a.pValue = ????
a.ulValueLen = 5;
Any idea ? Do I declare the structure wrongly ?
Thank you
Andrea
I have the followng problem using PInvoke:
Consider the following C structure
typedef struct ATTRIBUTE {
unsigned long type;
void* pValue;
unsigned long ulValueLen;
};
that is used in the following way
char[] alias = "pippo";
bool token = true;
ATTRIBUTE Template[] =
{
{ 0, &token, sizeof(token)},
{ 1, alias, strlen(alias)},
};
this array of ATTRIBUTE has to be passed to such function as
int C_FindObjectsInit(ATTRIBUTE [] attrArr);
If I "traslate" the previous C structure in C# as
[StructLayout(LayoutKind.Sequential)]
public struct ATTRIBUTE
{
public UInt32 type;
public IntPtr pValue;
public UInt32 ulValueLen;
}
I have problems using the C# structure ( in the second field of the
structure) :
ATTRIBUTE[] a = new ATTRIBUTE();
a.type = 0;
a.pValue = ????
a.ulValueLen = 5;
Any idea ? Do I declare the structure wrongly ?
Thank you
Andrea