Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem, Marshal.SizeOf VS sizeof()

前端 未结 3 2005
小蘑菇
小蘑菇 2020-12-13 18:56

I have the following struct:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WAVEHDR
{
    internal IntPtr lpData;   // pointer t         


        
3条回答
  •  星月不相逢
    2020-12-13 19:25

    2) As far as I know the sizeof can only be used with types that have a predefined size at the compile-time.

    So use Marshal.SizeOf(typeof(WAVEHDR)).

提交回复
热议问题