diff --git a/src/SetupApi/PublicAPI.Unshipped.txt b/src/SetupApi/PublicAPI.Unshipped.txt index e69de29b..0c8ebd8d 100644 --- a/src/SetupApi/PublicAPI.Unshipped.txt +++ b/src/SetupApi/PublicAPI.Unshipped.txt @@ -0,0 +1,10 @@ +PInvoke.SetupApi.DEVPROPKEY +PInvoke.SetupApi.DEVPROPKEY.DEVPROPKEY() -> void +PInvoke.SetupApi.DEVPROPKEY.fmtid -> System.Guid +PInvoke.SetupApi.DEVPROPKEY.pid -> uint +PInvoke.SetupApi.SetupDiGetDevicePropertyFlags +PInvoke.SetupApi.SetupDiGetDevicePropertyFlags.None = 0 -> PInvoke.SetupApi.SetupDiGetDevicePropertyFlags +static PInvoke.SetupApi.SetupDiGetDeviceProperty(PInvoke.SetupApi.SafeDeviceInfoSetHandle deviceInfoSet, PInvoke.SetupApi.SP_DEVINFO_DATA* deviceInfoData, PInvoke.SetupApi.DEVPROPKEY* propertyKey, uint* propertyType, byte[] propertyBuffer, uint propertyBufferSize, uint* requiredSize, PInvoke.SetupApi.SetupDiGetDevicePropertyFlags flags) -> bool +static PInvoke.SetupApi.SetupDiGetDeviceProperty(PInvoke.SetupApi.SafeDeviceInfoSetHandle deviceInfoSet, System.IntPtr deviceInfoData, System.IntPtr propertyKey, System.IntPtr propertyType, System.IntPtr propertyBuffer, uint propertyBufferSize, System.IntPtr requiredSize, PInvoke.SetupApi.SetupDiGetDevicePropertyFlags flags) -> bool +static PInvoke.SetupApi.SetupDiGetDeviceProperty(PInvoke.SetupApi.SafeDeviceInfoSetHandle deviceInfoSet, System.IntPtr deviceInfoData, System.IntPtr propertyKey, System.IntPtr propertyType, byte[] propertyBuffer, uint propertyBufferSize, System.IntPtr requiredSize, PInvoke.SetupApi.SetupDiGetDevicePropertyFlags flags) -> bool +static extern PInvoke.SetupApi.SetupDiGetDeviceProperty(PInvoke.SetupApi.SafeDeviceInfoSetHandle deviceInfoSet, PInvoke.SetupApi.SP_DEVINFO_DATA* deviceInfoData, PInvoke.SetupApi.DEVPROPKEY* propertyKey, uint* propertyType, byte* propertyBuffer, uint propertyBufferSize, uint* requiredSize, PInvoke.SetupApi.SetupDiGetDevicePropertyFlags flags) -> bool \ No newline at end of file diff --git a/src/SetupApi/SetupApi+DEVPROPKEY.cs b/src/SetupApi/SetupApi+DEVPROPKEY.cs new file mode 100644 index 00000000..7580cc8a --- /dev/null +++ b/src/SetupApi/SetupApi+DEVPROPKEY.cs @@ -0,0 +1,32 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace PInvoke +{ + using System; + using System.Collections.Generic; + using System.Text; + + /// + /// Contains the nested type. + /// + public partial class SetupApi + { + /// + /// In Windows Vista and later versions of Windows, the DEVPROPKEY structure represents a device property key for a device property in the + /// unified device property model. + /// + public struct DEVPROPKEY + { + /// + /// A value that specifies a property category. + /// + public Guid fmtid; + + /// + /// A value that uniquely identifies the property within the property category. For internal system reasons, a property identifier must be greater than or equal to two. + /// + public uint pid; + } + } +} diff --git a/src/SetupApi/SetupApi+SetupDiGetDevicePropertyFlags.cs b/src/SetupApi/SetupApi+SetupDiGetDevicePropertyFlags.cs new file mode 100644 index 00000000..41216b64 --- /dev/null +++ b/src/SetupApi/SetupApi+SetupDiGetDevicePropertyFlags.cs @@ -0,0 +1,25 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace PInvoke +{ + using System; + + /// + /// Contains the nested type. + /// + public partial class SetupApi + { + /// + /// Flags for the method. + /// + [Flags] + public enum SetupDiGetDevicePropertyFlags + { + /// + /// No flags. + /// + None = 0, + } + } +} diff --git a/src/SetupApi/SetupApi.cs b/src/SetupApi/SetupApi.cs index af9ff74a..151d530c 100644 --- a/src/SetupApi/SetupApi.cs +++ b/src/SetupApi/SetupApi.cs @@ -103,6 +103,7 @@ public static partial class SetupApi /// . /// [DllImport(nameof(SetupApi), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] public static extern unsafe bool SetupDiEnumDeviceInterfaces( SafeDeviceInfoSetHandle deviceInfoSet, [Friendly(FriendlyFlags.In | FriendlyFlags.Optional)] SP_DEVINFO_DATA* deviceInfoData, @@ -149,6 +150,7 @@ public static partial class SetupApi /// . /// [DllImport(nameof(SetupApi), SetLastError = true, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] public static extern unsafe bool SetupDiGetDeviceInterfaceDetail( SafeDeviceInfoSetHandle deviceInfoSet, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, @@ -176,11 +178,47 @@ public static partial class SetupApi /// . /// [DllImport(nameof(SetupApi), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] public static extern unsafe bool SetupDiEnumDeviceInfo( SafeDeviceInfoSetHandle deviceInfoSet, int memberIndex, SP_DEVINFO_DATA* deviceInfoData); + /// + /// Retrieves a device instance property. + /// + /// A handle to a device information set + /// that contains a device instance for which to retrieve a device instance property. + /// A pointer to the structure that represents the device instance for which to retrieve a device instance property. + /// A pointer to a structure that represents the device property key of the requested device instance property. + /// A pointer to a uint-typed variable that receives the property-data-type identifier of the requested device instance property, where the property-data-type + /// identifier is the bitwise OR between a base-data-type identifier and, if the base-data type is modified, a property-data-type modifier. + /// + /// A pointer to a buffer that receives the requested device instance property. + /// retrieves the requested property + /// only if the buffer is large enough to hold all the property value data. The pointer can be NULL. If the pointer is set to NULL and RequiredSize is supplied, + /// returns the size of the property, + /// in bytes, in . + /// The size, in bytes, of the buffer. If is set to NULL, must be set to zero. + /// + /// A pointer to a DWORD-typed variable that receives the size, in bytes, of either the device instance property if the property is retrieved or the required buffer size if the buffer is not large enough. This pointer can be set to NULL. + /// + /// This parameter must be set to zero. + /// + /// Returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error can be retrieved by calling . + /// + [DllImport(nameof(SetupApi), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern unsafe bool SetupDiGetDeviceProperty( + SafeDeviceInfoSetHandle deviceInfoSet, + SP_DEVINFO_DATA* deviceInfoData, + DEVPROPKEY* propertyKey, + uint* propertyType, + byte* propertyBuffer, + uint propertyBufferSize, + uint* requiredSize, + SetupDiGetDevicePropertyFlags flags); + /// /// Deletes a device information set and frees all associated memory. /// @@ -195,6 +233,7 @@ public static partial class SetupApi [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] #endif [DllImport(nameof(SetupApi), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet); } }