F#PInvoke等效

时间:2015-01-12 08:20:54

标签: c# f# pinvoke

给出以下C#代码:

[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);

等效的F#会是什么?

我假设它会像下面这样,但我不确定如何处理裁判。

[<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)

修改 在F#部分有错误的方法

0 个答案:

没有答案