Marshalling struct with embedded pointer from C# to unmanaged driver

后端 未结 3 571
闹比i
闹比i 2021-01-20 17:08

I\'m trying to interface C# (.NET Compact Framework 3.5) with a Windows CE 6 R2 stream driver using P/Invoked DeviceIoControl() calls . For one of the IOCTL codes, the driv

3条回答
  •  感情败类
    2021-01-20 17:33

    When marshaling a struct which has an inline pointer, you need to define the value as an IntPtr and not an array

    [StructLayout(LayoutKind.Sequential)]
    public struct IoctlWriteRegsIn
    {
        public uint Address;
        public IntPtr Buffer;
        public uint Size;
    }
    

提交回复
热议问题