I am wondering if every single field of a struct needs to be completely
attributed or if the runtime will marshall standard types "automagically"...
This would be the PInvok'd api call:
[DllImport("mywork.dll", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi)]
public static extern int GetSomeData(ref MYSTRUCT myStruct);
For example, given this struct:
[StructLayout(LayoutKind.Sequential,Pack=8)]
public struct MYSTRUCT
{
[MarshalAs(UnmanagedType.I4)]
public int iFieldOne;
[MarshalAs(UnmanagedType.U4)]
public uint dwFieldTwo;
[MarshalAs(UnmanagedType.U2)]
public short wFieldThree;
[MarshalAs(UnmanagedType.Bool)]
public bool bFieldFour;
}
would this be functionally the same as:
[StructLayout(LayoutKind.Sequential,Pack=8)]
public struct MYSTRUCT
{
public int iFieldOne;
public uint dwFieldTwo;
public short wFieldThree;
public bool bFieldFour;
}
Thanks in advance,
Brian Manlove
prakash.kgm@gmail.com - 14 Sep 2006 06:59 GMT
There is no need to give the MarshalAs() attribute for blittable types.
http://msdn2.microsoft.com/en-us/library/75dwhxf7.aspx
Regards
Prakash.
> I am wondering if every single field of a struct needs to be completely
> attributed or if the runtime will marshall standard types "automagically"...
[quoted text clipped - 36 lines]
> Thanks in advance,
> Brian Manlove