0

Given the following C# code:

[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVICE_INTERFACE_DATA
{
    public int cbSize;
    public Guid InterfaceClassGuid;
    public int Flags;
    public int Reserved;
}


[DllImport("setupapi.dll", CharSet=CharSet.Auto)]
public static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IntPtr DeviceInterfaceDetailData, int DeviceInterfaceDetailDataSize, ref int RequiredSize, IntPtr DeviceInfoData);

What would the equivalent F# be?

I am assuming it will be something like the following, but I am not sure exactly how to handle the refs.

[<Struct;StructLayout(LayoutKind.Sequential)>]
type SP_DEVICE_INTERFACE_DATA =
    val mutable cbSize: int
    val mutable InterfaceClassGuid: Guid
    val mutable Flags: int
    val mutable Reserved: int

[<DllImport("setupapi.dll", CharSet=CharSet.Auto)>]
extern bool SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet, SP_DEVICE_INTERFACE_DATA* DeviceInterfaceData, IntPtr DeviceInterfaceDetailData, int DeviceInterfaceDetailDataSize, int* RequiredSize, IntPtr DeviceInfoData)

Edit Had the wrong method in the F# section

AshtonKJ
  • 1,376
  • 2
  • 14
  • 22

0 Answers0