diff --git a/PInvoke/SetupAPI/CorrelationReport.md b/PInvoke/SetupAPI/CorrelationReport.md
index 787f4380..9bb270b3 100644
--- a/PInvoke/SetupAPI/CorrelationReport.md
+++ b/PInvoke/SetupAPI/CorrelationReport.md
@@ -3,7 +3,7 @@ PInvoke API (methods, structures and constants) imported from Windows SetupAPI.d
- Includes methods from setupapi.dll
- Current NuGet release: [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.SetupAPI?logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.SetupAPI?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.SetupAPI)
-### Methods - 12% API coverage (28 of 233 functions)
+### Methods - 52% API coverage (123 of 235 functions)
Native Method | Header | Managed Method
--- | --- | ---
[DriverStoreAddDriverPackage](https://www.google.com/search?num=5&q=DriverStoreAddDriverPackageA+site%3Adocs.microsoft.com) | |
@@ -38,115 +38,117 @@ Native Method | Header | Managed Method
[SetupDeleteError](https://www.google.com/search?num=5&q=SetupDeleteErrorA+site%3Adocs.microsoft.com) | |
[SetupDestroyDiskSpaceList](https://www.google.com/search?num=5&q=SetupDestroyDiskSpaceList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDestroyDiskSpaceList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDestroyDiskSpaceList)
[SetupDiApplyPowerScheme](https://www.google.com/search?num=5&q=SetupDiApplyPowerScheme+site%3Adocs.microsoft.com) | |
-[SetupDiAskForOEMDisk](https://www.google.com/search?num=5&q=SetupDiAskForOEMDisk+site%3Adocs.microsoft.com) | |
-[SetupDiBuildClassInfoList](https://www.google.com/search?num=5&q=SetupDiBuildClassInfoList+site%3Adocs.microsoft.com) | |
+[SetupDiAskForOEMDisk](https://www.google.com/search?num=5&q=SetupDiAskForOEMDisk+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiAskForOEMDisk](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiAskForOEMDisk)
+[SetupDiBuildClassInfoList](https://www.google.com/search?num=5&q=SetupDiBuildClassInfoList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiBuildClassInfoList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiBuildClassInfoList)
[SetupDiBuildClassInfoListEx](https://www.google.com/search?num=5&q=SetupDiBuildClassInfoListExA+site%3Adocs.microsoft.com) | |
-[SetupDiBuildDriverInfoList](https://www.google.com/search?num=5&q=SetupDiBuildDriverInfoList+site%3Adocs.microsoft.com) | |
-[SetupDiCallClassInstaller](https://www.google.com/search?num=5&q=SetupDiCallClassInstaller+site%3Adocs.microsoft.com) | |
-[SetupDiCancelDriverInfoSearch](https://www.google.com/search?num=5&q=SetupDiCancelDriverInfoSearch+site%3Adocs.microsoft.com) | |
-[SetupDiChangeState](https://www.google.com/search?num=5&q=SetupDiChangeState+site%3Adocs.microsoft.com) | |
-[SetupDiClassGuidsFromName](https://www.google.com/search?num=5&q=SetupDiClassGuidsFromNameA+site%3Adocs.microsoft.com) | |
-[SetupDiClassGuidsFromNameEx](https://www.google.com/search?num=5&q=SetupDiClassGuidsFromNameExA+site%3Adocs.microsoft.com) | |
+[SetupDiBuildClassInfoListExAA](https://www.google.com/search?num=5&q=SetupDiBuildClassInfoListExAA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiBuildClassInfoListExA](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiBuildClassInfoListExA)
+[SetupDiBuildClassInfoListExAW](https://www.google.com/search?num=5&q=SetupDiBuildClassInfoListExAW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiBuildClassInfoListExA](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiBuildClassInfoListExA)
+[SetupDiBuildDriverInfoList](https://www.google.com/search?num=5&q=SetupDiBuildDriverInfoList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiBuildDriverInfoList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiBuildDriverInfoList)
+[SetupDiCallClassInstaller](https://www.google.com/search?num=5&q=SetupDiCallClassInstaller+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCallClassInstaller](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCallClassInstaller)
+[SetupDiCancelDriverInfoSearch](https://www.google.com/search?num=5&q=SetupDiCancelDriverInfoSearch+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCancelDriverInfoSearch](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCancelDriverInfoSearch)
+[SetupDiChangeState](https://www.google.com/search?num=5&q=SetupDiChangeState+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiChangeState](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiChangeState)
+[SetupDiClassGuidsFromName](https://www.google.com/search?num=5&q=SetupDiClassGuidsFromNameA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiClassGuidsFromName](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiClassGuidsFromName)
+[SetupDiClassGuidsFromNameEx](https://www.google.com/search?num=5&q=SetupDiClassGuidsFromNameExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiClassGuidsFromNameEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiClassGuidsFromNameEx)
[SetupDiClassNameFromGuid](https://www.google.com/search?num=5&q=SetupDiClassNameFromGuidA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiClassNameFromGuid](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiClassNameFromGuid)
-[SetupDiClassNameFromGuidEx](https://www.google.com/search?num=5&q=SetupDiClassNameFromGuidExA+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDeviceInfo](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoA+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDeviceInfoList](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoList+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDeviceInfoListEx](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoListExA+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDeviceInterface](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInterfaceA+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInterfaceRegKeyA+site%3Adocs.microsoft.com) | |
-[SetupDiCreateDevRegKey](https://www.google.com/search?num=5&q=SetupDiCreateDevRegKeyA+site%3Adocs.microsoft.com) | |
-[SetupDiDeleteDeviceInfo](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInfo+site%3Adocs.microsoft.com) | |
-[SetupDiDeleteDeviceInterfaceData](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInterfaceData+site%3Adocs.microsoft.com) | |
-[SetupDiDeleteDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInterfaceRegKey+site%3Adocs.microsoft.com) | |
-[SetupDiDeleteDevRegKey](https://www.google.com/search?num=5&q=SetupDiDeleteDevRegKey+site%3Adocs.microsoft.com) | |
-[SetupDiDestroyClassImageList](https://www.google.com/search?num=5&q=SetupDiDestroyClassImageList+site%3Adocs.microsoft.com) | |
+[SetupDiClassNameFromGuidEx](https://www.google.com/search?num=5&q=SetupDiClassNameFromGuidExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiClassNameFromGuidEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiClassNameFromGuidEx)
+[SetupDiCreateDeviceInfo](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDeviceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDeviceInfo)
+[SetupDiCreateDeviceInfoList](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDeviceInfoList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDeviceInfoList)
+[SetupDiCreateDeviceInfoListEx](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInfoListExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDeviceInfoListEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDeviceInfoListEx)
+[SetupDiCreateDeviceInterface](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInterfaceA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDeviceInterface](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDeviceInterface)
+[SetupDiCreateDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiCreateDeviceInterfaceRegKeyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDeviceInterfaceRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDeviceInterfaceRegKey)
+[SetupDiCreateDevRegKey](https://www.google.com/search?num=5&q=SetupDiCreateDevRegKeyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiCreateDevRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiCreateDevRegKey)
+[SetupDiDeleteDeviceInfo](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInfo+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDeleteDeviceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDeleteDeviceInfo)
+[SetupDiDeleteDeviceInterfaceData](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInterfaceData+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDeleteDeviceInterfaceData](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDeleteDeviceInterfaceData)
+[SetupDiDeleteDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiDeleteDeviceInterfaceRegKey+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDeleteDeviceInterfaceRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDeleteDeviceInterfaceRegKey)
+[SetupDiDeleteDevRegKey](https://www.google.com/search?num=5&q=SetupDiDeleteDevRegKey+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDeleteDevRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDeleteDevRegKey)
+[SetupDiDestroyClassImageList](https://www.google.com/search?num=5&q=SetupDiDestroyClassImageList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDestroyClassImageList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDestroyClassImageList)
[SetupDiDestroyDeviceInfoList](https://www.google.com/search?num=5&q=SetupDiDestroyDeviceInfoList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDestroyDeviceInfoList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDestroyDeviceInfoList)
-[SetupDiDestroyDriverInfoList](https://www.google.com/search?num=5&q=SetupDiDestroyDriverInfoList+site%3Adocs.microsoft.com) | |
-[SetupDiDrawMiniIcon](https://www.google.com/search?num=5&q=SetupDiDrawMiniIcon+site%3Adocs.microsoft.com) | |
+[SetupDiDestroyDriverInfoList](https://www.google.com/search?num=5&q=SetupDiDestroyDriverInfoList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDestroyDriverInfoList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDestroyDriverInfoList)
+[SetupDiDrawMiniIcon](https://www.google.com/search?num=5&q=SetupDiDrawMiniIcon+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiDrawMiniIcon](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiDrawMiniIcon)
[SetupDiEnumDeviceInfo](https://www.google.com/search?num=5&q=SetupDiEnumDeviceInfo+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiEnumDeviceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiEnumDeviceInfo)
[SetupDiEnumDeviceInterfaces](https://www.google.com/search?num=5&q=SetupDiEnumDeviceInterfaces+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiEnumDeviceInterfaces](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiEnumDeviceInterfaces)
-[SetupDiEnumDriverInfo](https://www.google.com/search?num=5&q=SetupDiEnumDriverInfoA+site%3Adocs.microsoft.com) | |
-[SetupDiGetActualModelsSection](https://www.google.com/search?num=5&q=SetupDiGetActualModelsSectionA+site%3Adocs.microsoft.com) | |
-[SetupDiGetActualSectionToInstall](https://www.google.com/search?num=5&q=SetupDiGetActualSectionToInstallA+site%3Adocs.microsoft.com) | |
-[SetupDiGetActualSectionToInstallEx](https://www.google.com/search?num=5&q=SetupDiGetActualSectionToInstallExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassBitmapIndex](https://www.google.com/search?num=5&q=SetupDiGetClassBitmapIndex+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassDescription](https://www.google.com/search?num=5&q=SetupDiGetClassDescriptionA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassDescriptionEx](https://www.google.com/search?num=5&q=SetupDiGetClassDescriptionExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassDevPropertySheets](https://www.google.com/search?num=5&q=SetupDiGetClassDevPropertySheetsA+site%3Adocs.microsoft.com) | |
+[SetupDiEnumDriverInfo](https://www.google.com/search?num=5&q=SetupDiEnumDriverInfoA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiEnumDriverInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiEnumDriverInfo)
+[SetupDiGetActualModelsSection](https://www.google.com/search?num=5&q=SetupDiGetActualModelsSectionA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetActualModelsSection](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetActualModelsSection)
+[SetupDiGetActualSectionToInstall](https://www.google.com/search?num=5&q=SetupDiGetActualSectionToInstallA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetActualSectionToInstall](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetActualSectionToInstall)
+[SetupDiGetActualSectionToInstallEx](https://www.google.com/search?num=5&q=SetupDiGetActualSectionToInstallExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetActualSectionToInstallEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetActualSectionToInstallEx)
+[SetupDiGetClassBitmapIndex](https://www.google.com/search?num=5&q=SetupDiGetClassBitmapIndex+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassBitmapIndex](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassBitmapIndex)
+[SetupDiGetClassDescription](https://www.google.com/search?num=5&q=SetupDiGetClassDescriptionA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassDescription](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassDescription)
+[SetupDiGetClassDescriptionEx](https://www.google.com/search?num=5&q=SetupDiGetClassDescriptionExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassDescriptionEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassDescriptionEx)
+[SetupDiGetClassDevPropertySheets](https://www.google.com/search?num=5&q=SetupDiGetClassDevPropertySheetsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassDevPropertySheets](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassDevPropertySheets)
[SetupDiGetClassDevs](https://www.google.com/search?num=5&q=SetupDiGetClassDevsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassDevs](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassDevs)
-[SetupDiGetClassDevsEx](https://www.google.com/search?num=5&q=SetupDiGetClassDevsExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassImageIndex](https://www.google.com/search?num=5&q=SetupDiGetClassImageIndex+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassImageList](https://www.google.com/search?num=5&q=SetupDiGetClassImageList+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassImageListEx](https://www.google.com/search?num=5&q=SetupDiGetClassImageListExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassInstallParams](https://www.google.com/search?num=5&q=SetupDiGetClassInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassPropertyExW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyExW+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassPropertyKeys](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyKeys+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassPropertyKeysExW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyKeysExW+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassPropertyW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyW+site%3Adocs.microsoft.com) | |
-[SetupDiGetClassRegistryProperty](https://www.google.com/search?num=5&q=SetupDiGetClassRegistryPropertyA+site%3Adocs.microsoft.com) | |
-[SetupDiGetCustomDeviceProperty](https://www.google.com/search?num=5&q=SetupDiGetCustomDevicePropertyA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInfoListClass](https://www.google.com/search?num=5&q=SetupDiGetDeviceInfoListClass+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInfoListDetail](https://www.google.com/search?num=5&q=SetupDiGetDeviceInfoListDetailA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInstallParams](https://www.google.com/search?num=5&q=SetupDiGetDeviceInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInstanceId](https://www.google.com/search?num=5&q=SetupDiGetDeviceInstanceIdA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInterfaceAlias](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfaceAlias+site%3Adocs.microsoft.com) | |
+[SetupDiGetClassDevsEx](https://www.google.com/search?num=5&q=SetupDiGetClassDevsExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassDevsEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassDevsEx)
+[SetupDiGetClassImageIndex](https://www.google.com/search?num=5&q=SetupDiGetClassImageIndex+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassImageIndex](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassImageIndex)
+[SetupDiGetClassImageList](https://www.google.com/search?num=5&q=SetupDiGetClassImageList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassImageList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassImageList)
+[SetupDiGetClassImageListEx](https://www.google.com/search?num=5&q=SetupDiGetClassImageListExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassImageListEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassImageListEx)
+[SetupDiGetClassInstallParams](https://www.google.com/search?num=5&q=SetupDiGetClassInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassInstallParams)
+[SetupDiGetClassPropertyExW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyExW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassPropertyEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassPropertyEx)
+[SetupDiGetClassPropertyKeys](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyKeys+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassPropertyKeys](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassPropertyKeys)
+[SetupDiGetClassPropertyKeysExW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyKeysExW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassPropertyKeysEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassPropertyKeysEx)
+[SetupDiGetClassPropertyW](https://www.google.com/search?num=5&q=SetupDiGetClassPropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassProperty)
+[SetupDiGetClassRegistryProperty](https://www.google.com/search?num=5&q=SetupDiGetClassRegistryPropertyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetClassRegistryProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetClassRegistryProperty)
+[SetupDiGetCustomDeviceProperty](https://www.google.com/search?num=5&q=SetupDiGetCustomDevicePropertyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetCustomDeviceProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetCustomDeviceProperty)
+[SetupDiGetDeviceInfoListClass](https://www.google.com/search?num=5&q=SetupDiGetDeviceInfoListClass+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInfoListClass](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInfoListClass)
+[SetupDiGetDeviceInfoListDetail](https://www.google.com/search?num=5&q=SetupDiGetDeviceInfoListDetailA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInfoListDetail](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInfoListDetail)
+[SetupDiGetDeviceInstallParams](https://www.google.com/search?num=5&q=SetupDiGetDeviceInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInstallParams)
+[SetupDiGetDeviceInstanceId](https://www.google.com/search?num=5&q=SetupDiGetDeviceInstanceIdA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInstanceId](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInstanceId)
+[SetupDiGetDeviceInterfaceAlias](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfaceAlias+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInterfaceAlias](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInterfaceAlias)
[SetupDiGetDeviceInterfaceDetail](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfaceDetailA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInterfaceDetail](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInterfaceDetail)
-[SetupDiGetDeviceInterfacePropertyKeys](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfacePropertyKeys+site%3Adocs.microsoft.com) | |
-[SetupDiGetDeviceInterfacePropertyW](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfacePropertyW+site%3Adocs.microsoft.com) | |
+[SetupDiGetDeviceInterfacePropertyKeys](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfacePropertyKeys+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInterfacePropertyKeys](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInterfacePropertyKeys)
+[SetupDiGetDeviceInterfacePropertyW](https://www.google.com/search?num=5&q=SetupDiGetDeviceInterfacePropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceInterfaceProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceInterfaceProperty)
[SetupDiGetDevicePropertyKeys](https://www.google.com/search?num=5&q=SetupDiGetDevicePropertyKeys+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDevicePropertyKeys](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDevicePropertyKeys)
[SetupDiGetDevicePropertyW](https://www.google.com/search?num=5&q=SetupDiGetDevicePropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceProperty)
-[SetupDiGetDeviceRegistryProperty](https://www.google.com/search?num=5&q=SetupDiGetDeviceRegistryPropertyA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDriverInfoDetail](https://www.google.com/search?num=5&q=SetupDiGetDriverInfoDetailA+site%3Adocs.microsoft.com) | |
-[SetupDiGetDriverInstallParams](https://www.google.com/search?num=5&q=SetupDiGetDriverInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiGetHwProfileFriendlyName](https://www.google.com/search?num=5&q=SetupDiGetHwProfileFriendlyNameA+site%3Adocs.microsoft.com) | |
-[SetupDiGetHwProfileFriendlyNameEx](https://www.google.com/search?num=5&q=SetupDiGetHwProfileFriendlyNameExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetHwProfileList](https://www.google.com/search?num=5&q=SetupDiGetHwProfileList+site%3Adocs.microsoft.com) | |
-[SetupDiGetHwProfileListEx](https://www.google.com/search?num=5&q=SetupDiGetHwProfileListExA+site%3Adocs.microsoft.com) | |
-[SetupDiGetINFClass](https://www.google.com/search?num=5&q=SetupDiGetINFClassA+site%3Adocs.microsoft.com) | |
-[SetupDiGetSelectedDevice](https://www.google.com/search?num=5&q=SetupDiGetSelectedDevice+site%3Adocs.microsoft.com) | |
-[SetupDiGetSelectedDriver](https://www.google.com/search?num=5&q=SetupDiGetSelectedDriverA+site%3Adocs.microsoft.com) | |
+[SetupDiGetDeviceRegistryProperty](https://www.google.com/search?num=5&q=SetupDiGetDeviceRegistryPropertyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDeviceRegistryProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDeviceRegistryProperty)
+[SetupDiGetDriverInfoDetail](https://www.google.com/search?num=5&q=SetupDiGetDriverInfoDetailA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDriverInfoDetail](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDriverInfoDetail)
+[SetupDiGetDriverInstallParams](https://www.google.com/search?num=5&q=SetupDiGetDriverInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetDriverInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetDriverInstallParams)
+[SetupDiGetHwProfileFriendlyName](https://www.google.com/search?num=5&q=SetupDiGetHwProfileFriendlyNameA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetHwProfileFriendlyName](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetHwProfileFriendlyName)
+[SetupDiGetHwProfileFriendlyNameEx](https://www.google.com/search?num=5&q=SetupDiGetHwProfileFriendlyNameExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetHwProfileFriendlyNameEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetHwProfileFriendlyNameEx)
+[SetupDiGetHwProfileList](https://www.google.com/search?num=5&q=SetupDiGetHwProfileList+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetHwProfileList](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetHwProfileList)
+[SetupDiGetHwProfileListEx](https://www.google.com/search?num=5&q=SetupDiGetHwProfileListExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetHwProfileListEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetHwProfileListEx)
+[SetupDiGetINFClass](https://www.google.com/search?num=5&q=SetupDiGetINFClassA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetINFClass](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetINFClass)
+[SetupDiGetSelectedDevice](https://www.google.com/search?num=5&q=SetupDiGetSelectedDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetSelectedDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetSelectedDevice)
+[SetupDiGetSelectedDriver](https://www.google.com/search?num=5&q=SetupDiGetSelectedDriverA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiGetSelectedDriver](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiGetSelectedDriver)
[SetupDiGetWizardPage](https://www.google.com/search?num=5&q=SetupDiGetWizardPage+site%3Adocs.microsoft.com) | |
-[SetupDiInstallClass](https://www.google.com/search?num=5&q=SetupDiInstallClassA+site%3Adocs.microsoft.com) | |
-[SetupDiInstallClassEx](https://www.google.com/search?num=5&q=SetupDiInstallClassExA+site%3Adocs.microsoft.com) | |
-[SetupDiInstallDevice](https://www.google.com/search?num=5&q=SetupDiInstallDevice+site%3Adocs.microsoft.com) | |
-[SetupDiInstallDeviceInterfaces](https://www.google.com/search?num=5&q=SetupDiInstallDeviceInterfaces+site%3Adocs.microsoft.com) | |
-[SetupDiInstallDriverFiles](https://www.google.com/search?num=5&q=SetupDiInstallDriverFiles+site%3Adocs.microsoft.com) | |
-[SetupDiLoadClassIcon](https://www.google.com/search?num=5&q=SetupDiLoadClassIcon+site%3Adocs.microsoft.com) | |
-[SetupDiLoadDeviceIcon](https://www.google.com/search?num=5&q=SetupDiLoadDeviceIcon+site%3Adocs.microsoft.com) | |
+[SetupDiInstallClass](https://www.google.com/search?num=5&q=SetupDiInstallClassA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiInstallClass](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiInstallClass)
+[SetupDiInstallClassEx](https://www.google.com/search?num=5&q=SetupDiInstallClassExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiInstallClassEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiInstallClassEx)
+[SetupDiInstallDevice](https://www.google.com/search?num=5&q=SetupDiInstallDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiInstallDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiInstallDevice)
+[SetupDiInstallDeviceInterfaces](https://www.google.com/search?num=5&q=SetupDiInstallDeviceInterfaces+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiInstallDeviceInterfaces](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiInstallDeviceInterfaces)
+[SetupDiInstallDriverFiles](https://www.google.com/search?num=5&q=SetupDiInstallDriverFiles+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiInstallDriverFiles](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiInstallDriverFiles)
+[SetupDiLoadClassIcon](https://www.google.com/search?num=5&q=SetupDiLoadClassIcon+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiLoadClassIcon](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiLoadClassIcon)
+[SetupDiLoadDeviceIcon](https://www.google.com/search?num=5&q=SetupDiLoadDeviceIcon+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiLoadDeviceIcon](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiLoadDeviceIcon)
[SetupDiMoveDuplicateDevice](https://www.google.com/search?num=5&q=SetupDiMoveDuplicateDevice+site%3Adocs.microsoft.com) | |
-[SetupDiOpenClassRegKey](https://www.google.com/search?num=5&q=SetupDiOpenClassRegKey+site%3Adocs.microsoft.com) | |
-[SetupDiOpenClassRegKeyEx](https://www.google.com/search?num=5&q=SetupDiOpenClassRegKeyExA+site%3Adocs.microsoft.com) | |
-[SetupDiOpenDeviceInfo](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInfoA+site%3Adocs.microsoft.com) | |
-[SetupDiOpenDeviceInterface](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInterfaceA+site%3Adocs.microsoft.com) | |
-[SetupDiOpenDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInterfaceRegKey+site%3Adocs.microsoft.com) | |
-[SetupDiOpenDevRegKey](https://www.google.com/search?num=5&q=SetupDiOpenDevRegKey+site%3Adocs.microsoft.com) | |
-[SetupDiRegisterCoDeviceInstallers](https://www.google.com/search?num=5&q=SetupDiRegisterCoDeviceInstallers+site%3Adocs.microsoft.com) | |
-[SetupDiRegisterDeviceInfo](https://www.google.com/search?num=5&q=SetupDiRegisterDeviceInfo+site%3Adocs.microsoft.com) | |
-[SetupDiRemoveDevice](https://www.google.com/search?num=5&q=SetupDiRemoveDevice+site%3Adocs.microsoft.com) | |
-[SetupDiRemoveDeviceInterface](https://www.google.com/search?num=5&q=SetupDiRemoveDeviceInterface+site%3Adocs.microsoft.com) | |
+[SetupDiOpenClassRegKey](https://www.google.com/search?num=5&q=SetupDiOpenClassRegKey+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenClassRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenClassRegKey)
+[SetupDiOpenClassRegKeyEx](https://www.google.com/search?num=5&q=SetupDiOpenClassRegKeyExA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenClassRegKeyEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenClassRegKeyEx)
+[SetupDiOpenDeviceInfo](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInfoA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenDeviceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenDeviceInfo)
+[SetupDiOpenDeviceInterface](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInterfaceA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenDeviceInterface](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenDeviceInterface)
+[SetupDiOpenDeviceInterfaceRegKey](https://www.google.com/search?num=5&q=SetupDiOpenDeviceInterfaceRegKey+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenDeviceInterfaceRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenDeviceInterfaceRegKey)
+[SetupDiOpenDevRegKey](https://www.google.com/search?num=5&q=SetupDiOpenDevRegKey+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiOpenDevRegKey](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiOpenDevRegKey)
+[SetupDiRegisterCoDeviceInstallers](https://www.google.com/search?num=5&q=SetupDiRegisterCoDeviceInstallers+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiRegisterCoDeviceInstallers](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiRegisterCoDeviceInstallers)
+[SetupDiRegisterDeviceInfo](https://www.google.com/search?num=5&q=SetupDiRegisterDeviceInfo+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiRegisterDeviceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiRegisterDeviceInfo)
+[SetupDiRemoveDevice](https://www.google.com/search?num=5&q=SetupDiRemoveDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiRemoveDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiRemoveDevice)
+[SetupDiRemoveDeviceInterface](https://www.google.com/search?num=5&q=SetupDiRemoveDeviceInterface+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiRemoveDeviceInterface](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiRemoveDeviceInterface)
[SetupDiReportAdditionalSoftwareRequested](https://www.google.com/search?num=5&q=SetupDiReportAdditionalSoftwareRequested+site%3Adocs.microsoft.com) | |
[SetupDiReportDeviceInstallError](https://www.google.com/search?num=5&q=SetupDiReportDeviceInstallError+site%3Adocs.microsoft.com) | |
[SetupDiReportDriverNotFoundError](https://www.google.com/search?num=5&q=SetupDiReportDriverNotFoundError+site%3Adocs.microsoft.com) | |
[SetupDiReportDriverPackageImportationError](https://www.google.com/search?num=5&q=SetupDiReportDriverPackageImportationError+site%3Adocs.microsoft.com) | |
[SetupDiReportGenericDriverInstalled](https://www.google.com/search?num=5&q=SetupDiReportGenericDriverInstalled+site%3Adocs.microsoft.com) | |
[SetupDiReportPnPDeviceProblem](https://www.google.com/search?num=5&q=SetupDiReportPnPDeviceProblem+site%3Adocs.microsoft.com) | |
-[SetupDiRestartDevices](https://www.google.com/search?num=5&q=SetupDiRestartDevices+site%3Adocs.microsoft.com) | |
-[SetupDiSelectBestCompatDrv](https://www.google.com/search?num=5&q=SetupDiSelectBestCompatDrv+site%3Adocs.microsoft.com) | |
-[SetupDiSelectDevice](https://www.google.com/search?num=5&q=SetupDiSelectDevice+site%3Adocs.microsoft.com) | |
-[SetupDiSelectOEMDrv](https://www.google.com/search?num=5&q=SetupDiSelectOEMDrv+site%3Adocs.microsoft.com) | |
-[SetupDiSetClassInstallParams](https://www.google.com/search?num=5&q=SetupDiSetClassInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiSetClassPropertyExW](https://www.google.com/search?num=5&q=SetupDiSetClassPropertyExW+site%3Adocs.microsoft.com) | |
-[SetupDiSetClassPropertyW](https://www.google.com/search?num=5&q=SetupDiSetClassPropertyW+site%3Adocs.microsoft.com) | |
-[SetupDiSetClassRegistryProperty](https://www.google.com/search?num=5&q=SetupDiSetClassRegistryPropertyA+site%3Adocs.microsoft.com) | |
-[SetupDiSetDeviceInstallParams](https://www.google.com/search?num=5&q=SetupDiSetDeviceInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiSetDeviceInterfaceDefault](https://www.google.com/search?num=5&q=SetupDiSetDeviceInterfaceDefault+site%3Adocs.microsoft.com) | |
-[SetupDiSetDeviceInterfacePropertyW](https://www.google.com/search?num=5&q=SetupDiSetDeviceInterfacePropertyW+site%3Adocs.microsoft.com) | |
-[SetupDiSetDevicePropertyW](https://www.google.com/search?num=5&q=SetupDiSetDevicePropertyW+site%3Adocs.microsoft.com) | |
-[SetupDiSetDeviceRegistryProperty](https://www.google.com/search?num=5&q=SetupDiSetDeviceRegistryPropertyA+site%3Adocs.microsoft.com) | |
-[SetupDiSetDriverInstallParams](https://www.google.com/search?num=5&q=SetupDiSetDriverInstallParamsA+site%3Adocs.microsoft.com) | |
-[SetupDiSetSelectedDevice](https://www.google.com/search?num=5&q=SetupDiSetSelectedDevice+site%3Adocs.microsoft.com) | |
-[SetupDiSetSelectedDriver](https://www.google.com/search?num=5&q=SetupDiSetSelectedDriverA+site%3Adocs.microsoft.com) | |
-[SetupDiUnremoveDevice](https://www.google.com/search?num=5&q=SetupDiUnremoveDevice+site%3Adocs.microsoft.com) | |
+[SetupDiRestartDevices](https://www.google.com/search?num=5&q=SetupDiRestartDevices+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiRestartDevices](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiRestartDevices)
+[SetupDiSelectBestCompatDrv](https://www.google.com/search?num=5&q=SetupDiSelectBestCompatDrv+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSelectBestCompatDrv](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSelectBestCompatDrv)
+[SetupDiSelectDevice](https://www.google.com/search?num=5&q=SetupDiSelectDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSelectDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSelectDevice)
+[SetupDiSelectOEMDrv](https://www.google.com/search?num=5&q=SetupDiSelectOEMDrv+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSelectOEMDrv](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSelectOEMDrv)
+[SetupDiSetClassInstallParams](https://www.google.com/search?num=5&q=SetupDiSetClassInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetClassInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetClassInstallParams)
+[SetupDiSetClassPropertyExW](https://www.google.com/search?num=5&q=SetupDiSetClassPropertyExW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetClassPropertyEx](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetClassPropertyEx)
+[SetupDiSetClassPropertyW](https://www.google.com/search?num=5&q=SetupDiSetClassPropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetClassProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetClassProperty)
+[SetupDiSetClassRegistryProperty](https://www.google.com/search?num=5&q=SetupDiSetClassRegistryPropertyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetClassRegistryProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetClassRegistryProperty)
+[SetupDiSetDeviceInstallParams](https://www.google.com/search?num=5&q=SetupDiSetDeviceInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDeviceInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDeviceInstallParams)
+[SetupDiSetDeviceInterfaceDefault](https://www.google.com/search?num=5&q=SetupDiSetDeviceInterfaceDefault+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDeviceInterfaceDefault](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDeviceInterfaceDefault)
+[SetupDiSetDeviceInterfacePropertyW](https://www.google.com/search?num=5&q=SetupDiSetDeviceInterfacePropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDeviceInterfaceProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDeviceInterfaceProperty)
+[SetupDiSetDevicePropertyW](https://www.google.com/search?num=5&q=SetupDiSetDevicePropertyW+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDeviceProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDeviceProperty)
+[SetupDiSetDeviceRegistryProperty](https://www.google.com/search?num=5&q=SetupDiSetDeviceRegistryPropertyA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDeviceRegistryProperty](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDeviceRegistryProperty)
+[SetupDiSetDriverInstallParams](https://www.google.com/search?num=5&q=SetupDiSetDriverInstallParamsA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetDriverInstallParams](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetDriverInstallParams)
+[SetupDiSetSelectedDevice](https://www.google.com/search?num=5&q=SetupDiSetSelectedDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetSelectedDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetSelectedDevice)
+[SetupDiSetSelectedDriver](https://www.google.com/search?num=5&q=SetupDiSetSelectedDriverA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiSetSelectedDriver](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiSetSelectedDriver)
+[SetupDiUnremoveDevice](https://www.google.com/search?num=5&q=SetupDiUnremoveDevice+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupDiUnremoveDevice](https://github.com/dahall/Vanara/search?l=C%23&q=SetupDiUnremoveDevice)
[SetupDuplicateDiskSpaceList](https://www.google.com/search?num=5&q=SetupDuplicateDiskSpaceListA+site%3Adocs.microsoft.com) | |
[SetupEnumInfSections](https://www.google.com/search?num=5&q=SetupEnumInfSectionsA+site%3Adocs.microsoft.com) | |
[SetupEnumPublishedInf](https://www.google.com/search?num=5&q=SetupEnumPublishedInfA+site%3Adocs.microsoft.com) | |
@@ -194,7 +196,7 @@ Native Method | Header | Managed Method
[SetupLogFile](https://www.google.com/search?num=5&q=SetupLogFileA+site%3Adocs.microsoft.com) | |
[SetupOpenAppendInfFile](https://www.google.com/search?num=5&q=SetupOpenAppendInfFileA+site%3Adocs.microsoft.com) | |
[SetupOpenFileQueue](https://www.google.com/search?num=5&q=SetupOpenFileQueue+site%3Adocs.microsoft.com) | |
-[SetupOpenInfFile](https://www.google.com/search?num=5&q=SetupOpenInfFileA+site%3Adocs.microsoft.com) | |
+[SetupOpenInfFile](https://www.google.com/search?num=5&q=SetupOpenInfFileA+site%3Adocs.microsoft.com) | setupapi.h | [Vanara.PInvoke.SetupAPI.SetupOpenInfFile](https://github.com/dahall/Vanara/search?l=C%23&q=SetupOpenInfFile)
[SetupOpenLog](https://www.google.com/search?num=5&q=SetupOpenLog+site%3Adocs.microsoft.com) | |
[SetupOpenMasterInf](https://www.google.com/search?num=5&q=SetupOpenMasterInf+site%3Adocs.microsoft.com) | |
[SetupPrepareQueueForRestore](https://www.google.com/search?num=5&q=SetupPrepareQueueForRestoreA+site%3Adocs.microsoft.com) | |
diff --git a/PInvoke/SetupAPI/SetupAPI.DiFuncs.cs b/PInvoke/SetupAPI/SetupAPI.DiFuncs.cs
index e7aee941..87da3174 100644
--- a/PInvoke/SetupAPI/SetupAPI.DiFuncs.cs
+++ b/PInvoke/SetupAPI/SetupAPI.DiFuncs.cs
@@ -11,6 +11,670 @@ namespace Vanara.PInvoke
/// Items from the SetupAPI.dll
public static partial class SetupAPI
{
+ /// A comparison callback function to use in duplicate detection.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device to register. The
+ /// device information set must not contain any remote elements.
+ ///
+ /// The new device data.
+ /// The existing device data.
+ ///
+ /// A pointer to a caller-supplied context buffer that is passed into the callback function. This parameter is ignored if
+ /// CompareProc is not specified.
+ ///
+ ///
+ /// The compare function must return ERROR_DUPLICATE_FOUND if it finds that the two devices are duplicates. Otherwise, it should
+ /// return NO_ERROR. If some other error is encountered, the callback function should return the appropriate ERROR_* code to
+ /// indicate the failure.
+ ///
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ public delegate Win32Error PSP_DETSIG_CMPPROC([In] HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA NewDeviceData,
+ in SP_DEVINFO_DATA ExistingDeviceData, [In, Optional] IntPtr CompareContext);
+
+ ///
+ /// The SetupDiAskForOEMDisk function displays a dialog that asks the user for the path of an OEM installation disk.
+ ///
+ ///
+ /// A handle to a device information set for the local computer. This set contains a device information element that represents the
+ /// device that is being installed.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiAskForOEMDisk associates the driver with the
+ /// device that is being installed. If this parameter is NULL, SetupDiAskForOEMDisk associates the driver with the
+ /// global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful and the DriverPath field of the SP_DEVINSTALLPARAMS structure is
+ /// updated to reflect the new path. If the user cancels the dialog, the function returns FALSE and a call to GetLastError
+ /// returns ERROR_CANCELLED.
+ ///
+ ///
+ ///
+ /// SetupDiAskForOEMDisk allows the user to browse local and network drives for OEM installation files. However,
+ /// SetupDiAskForOEMDisk is primarily designed to obtain the path of an OEM driver on a local computer before selecting and
+ /// installing the driver for a device on that computer.
+ ///
+ ///
+ /// Although this function will not fail if the device information set if for a remote computer, the result is of limited use
+ /// because the device information set cannot subsequently be used with DIF_Xxx installation requests or SetupDi Xxx
+ /// functions that do not support operations on a remote computer.
+ ///
+ ///
+ /// In particular, the device information set cannot be used as input with a DIF_SELECTDEVICE installation request to select a
+ /// driver for a device, followed by a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiaskforoemdisk WINSETUPAPI BOOL
+ // SetupDiAskForOEMDisk( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiAskForOEMDisk")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiAskForOEMDisk(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiAskForOEMDisk function displays a dialog that asks the user for the path of an OEM installation disk.
+ ///
+ ///
+ /// A handle to a device information set for the local computer. This set contains a device information element that represents the
+ /// device that is being installed.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiAskForOEMDisk associates the driver with the
+ /// device that is being installed. If this parameter is NULL, SetupDiAskForOEMDisk associates the driver with the
+ /// global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful and the DriverPath field of the SP_DEVINSTALLPARAMS structure is
+ /// updated to reflect the new path. If the user cancels the dialog, the function returns FALSE and a call to GetLastError
+ /// returns ERROR_CANCELLED.
+ ///
+ ///
+ ///
+ /// SetupDiAskForOEMDisk allows the user to browse local and network drives for OEM installation files. However,
+ /// SetupDiAskForOEMDisk is primarily designed to obtain the path of an OEM driver on a local computer before selecting and
+ /// installing the driver for a device on that computer.
+ ///
+ ///
+ /// Although this function will not fail if the device information set if for a remote computer, the result is of limited use
+ /// because the device information set cannot subsequently be used with DIF_Xxx installation requests or SetupDi Xxx
+ /// functions that do not support operations on a remote computer.
+ ///
+ ///
+ /// In particular, the device information set cannot be used as input with a DIF_SELECTDEVICE installation request to select a
+ /// driver for a device, followed by a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiaskforoemdisk WINSETUPAPI BOOL
+ // SetupDiAskForOEMDisk( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiAskForOEMDisk")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiAskForOEMDisk(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
+
+ ///
+ /// The SetupDiBuildClassInfoList function returns a list of setup class GUIDs that identify the classes that are installed
+ /// on a local computer.
+ ///
+ ///
+ ///
+ /// Flags used to control exclusion of classes from the list. If no flags are specified, all setup classes are included in the list.
+ /// Can be a combination of the following values:
+ ///
+ /// DIBCI_NOINSTALLCLASS
+ /// Exclude a class if it has the NoInstallClass value entry in its registry key.
+ /// DIBCI_NODISPLAYCLASS
+ /// Exclude a class if it has the NoDisplayClass value entry in its registry key.
+ ///
+ ///
+ /// A pointer to a GUID-typed array that receives a list of setup class GUIDs. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// The number of GUIDs in the array that is pointed to by the ClassGuildList parameter. If ClassGuidList is NULL,
+ /// ClassGuidSize must be zero.
+ ///
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of GUIDs that are returned (if the number is less than or equal to
+ /// the size, in GUIDs, of the array that is pointed to by the ClassGuidList parameter).
+ ///
+ ///
+ /// If this number is greater than the size of the ClassGuidList array, it indicates how large the ClassGuidList array must be in
+ /// order to contain all the class GUIDs.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ ///
+ /// To retrieve the number of classes that are installed on a local computer, call SetupDiBuildClassInfoList with
+ /// ClassGuidList set to NULL and ClassGuidSize set to zero. In response to such a call, the function returns the number of
+ /// classes in * RequiredSize.
+ ///
+ ///
+ /// SetupDiBuildClassInfoList does not return a class GUID for a class if the NoUseClass value entry exists in the
+ /// registry key of the class.
+ ///
+ /// To retrieve the list of setup class GUIDs installed on a remote system use SetupDiBuildClassInfoListEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdibuildclassinfolist WINSETUPAPI BOOL
+ // SetupDiBuildClassInfoList( DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildClassInfoList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiBuildClassInfoList(DIBCI Flags, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] ClassGuidList,
+ uint ClassGuidListSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiBuildClassInfoListEx function returns a list of setup class GUIDs that includes every class installed on the
+ /// local system or a remote system.
+ ///
+ ///
+ ///
+ /// Flags used to control exclusion of classes from the list. If no flags are specified, all setup classes are included in the list.
+ /// Can be a combination of the following values:
+ ///
+ /// DIBCI_NOINSTALLCLASS
+ /// Exclude a class if it has the NoInstallClass value entry in its registry key.
+ /// DIBCI_NODISPLAYCLASS
+ /// Exclude a class if it has the NoDisplayClass value entry in its registry key.
+ ///
+ /// A pointer to a buffer that receives a list of setup class GUIDs.
+ /// Supplies the number of GUIDs in the ClassGuildList array.
+ ///
+ /// A pointer to a variable that receives the number of GUIDs returned. If this number is greater than the size of the
+ /// ClassGuidList, the number indicates how large the ClassGuidList array must be in order to contain the list.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote computer from which to retrieve installed setup
+ /// classes. This parameter is optional and can be NULL. If MachineName is NULL, this function builds a list of
+ /// classes installed on the local computer.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdibuildclassinfolistexa WINSETUPAPI BOOL
+ // SetupDiBuildClassInfoListExA( DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCSTR MachineName,
+ // PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildClassInfoListExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiBuildClassInfoListExA(DIBCI Flags, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] ClassGuidList,
+ uint ClassGuidListSize, out uint RequiredSize, [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, IntPtr Reserved = default);
+
+ ///
+ /// The SetupDiBuildDriverInfoList function builds a list of drivers that is associated with a specific device or with the
+ /// global class driver list for a device information set.
+ ///
+ ///
+ /// A handle to the device information set to contain the driver list, either globally for all device information elements or
+ /// specifically for a single device information element. The device information set must not contain remote device information elements.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure for the device information element in DeviceInfoSet that represents the device for
+ /// which to build a driver list. This parameter is optional and can be NULL. If this parameter is specified, the list is
+ /// associated with the specified device. If this parameter is NULL, the list is associated with the global class driver list
+ /// for DeviceInfoSet.
+ ///
+ ///
+ /// If the class of this device is updated because of building a compatible driver list, DeviceInfoData. ClassGuid is updated
+ /// upon return.
+ ///
+ ///
+ ///
+ /// The type of driver list to build. Must be one of the following values:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// SPDIT_CLASSDRIVER
+ /// Build a list of class drivers. If DeviceInfoData is NULL, this driver list type must be specified.
+ ///
+ /// -
+ /// SPDIT_COMPATDRIVER
+ /// Build a list of compatible drivers. DeviceInfoData must not be NULL if this driver list type is specified.
+ ///
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ ///
+ /// The device information set should be for a local computer because SetupDiBuildDriverInfoList searches for drivers only on
+ /// a local computer. If the device information set is for a remote computer, the function returns TRUE but does not actually
+ /// update the existing driver list for the device information set or, if supplied, the driver list for the device information element.
+ ///
+ ///
+ /// The caller can set Flags in the SP_DEVINSTALL_PARAMS that are associated with the device information set or with a
+ /// specific device (DeviceInfoData) to control how the list is built. For example, the caller can set the
+ /// DI_FLAGSEX_ALLOWEXCLUDEDDRVS flag to include drivers that are marked Exclude From Select.
+ ///
+ ///
+ /// A driver is "Exclude From Select" if either it is marked ExcludeFromSelect in the INF file or it is a driver for a device
+ /// whose whole setup class is marked NoInstallClass or NoUseClass in the class installer INF file. Drivers for PnP
+ /// devices are typically "Exclude From Select"; PnP devices should not be manually installed. To build a list of driver files for a
+ /// PnP device a caller of SetupDiBuildDriverInfoList must set this flag.
+ ///
+ ///
+ /// The DriverPath in the SP_DEVINSTALL_PARAMS contains either a path of a directory that contain INF files or a path of a
+ /// specific INF file. If DI_ENUMSINGLEINF is set, DriverPath contains a path of a single INF file. If
+ /// DriverPath is NULL, this function builds the driver list from the default INF file location, %SystemRoot%\inf.
+ ///
+ ///
+ /// After this function has built the specified driver list, the caller can enumerate the elements of the list by calling SetupDiEnumDriverInfo.
+ ///
+ ///
+ /// If the driver list is associated with a device instance (that is, DeviceInfoData is specified), the resulting list is composed
+ /// of drivers that have the same class as the device instance with which they are associated. If this is a global class driver list
+ /// (that is, DriverType is SPDIT_CLASSDRIVER and DeviceInfoData is not specified), the class that is used when building the
+ /// list is the class associated with the device information set. If the device information set has no associated class, drivers of
+ /// all classes are used when building the list.
+ ///
+ /// Another thread can terminate the building of a driver list by a call to SetupDiCancelDriverInfoSearch.
+ /// The DeviceInfoSet must only contain elements on the local computer. This function only searches for local drivers.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdibuilddriverinfolist WINSETUPAPI BOOL
+ // SetupDiBuildDriverInfoList( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildDriverInfoList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiBuildDriverInfoList(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPDIT DriverType);
+
+ ///
+ /// The SetupDiBuildDriverInfoList function builds a list of drivers that is associated with a specific device or with the
+ /// global class driver list for a device information set.
+ ///
+ ///
+ /// A handle to the device information set to contain the driver list, either globally for all device information elements or
+ /// specifically for a single device information element. The device information set must not contain remote device information elements.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure for the device information element in DeviceInfoSet that represents the device for
+ /// which to build a driver list. This parameter is optional and can be NULL. If this parameter is specified, the list is
+ /// associated with the specified device. If this parameter is NULL, the list is associated with the global class driver list
+ /// for DeviceInfoSet.
+ ///
+ ///
+ /// If the class of this device is updated because of building a compatible driver list, DeviceInfoData. ClassGuid is updated
+ /// upon return.
+ ///
+ ///
+ ///
+ /// The type of driver list to build. Must be one of the following values:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// SPDIT_CLASSDRIVER
+ /// Build a list of class drivers. If DeviceInfoData is NULL, this driver list type must be specified.
+ ///
+ /// -
+ /// SPDIT_COMPATDRIVER
+ /// Build a list of compatible drivers. DeviceInfoData must not be NULL if this driver list type is specified.
+ ///
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ ///
+ /// The device information set should be for a local computer because SetupDiBuildDriverInfoList searches for drivers only on
+ /// a local computer. If the device information set is for a remote computer, the function returns TRUE but does not actually
+ /// update the existing driver list for the device information set or, if supplied, the driver list for the device information element.
+ ///
+ ///
+ /// The caller can set Flags in the SP_DEVINSTALL_PARAMS that are associated with the device information set or with a
+ /// specific device (DeviceInfoData) to control how the list is built. For example, the caller can set the
+ /// DI_FLAGSEX_ALLOWEXCLUDEDDRVS flag to include drivers that are marked Exclude From Select.
+ ///
+ ///
+ /// A driver is "Exclude From Select" if either it is marked ExcludeFromSelect in the INF file or it is a driver for a device
+ /// whose whole setup class is marked NoInstallClass or NoUseClass in the class installer INF file. Drivers for PnP
+ /// devices are typically "Exclude From Select"; PnP devices should not be manually installed. To build a list of driver files for a
+ /// PnP device a caller of SetupDiBuildDriverInfoList must set this flag.
+ ///
+ ///
+ /// The DriverPath in the SP_DEVINSTALL_PARAMS contains either a path of a directory that contain INF files or a path of a
+ /// specific INF file. If DI_ENUMSINGLEINF is set, DriverPath contains a path of a single INF file. If
+ /// DriverPath is NULL, this function builds the driver list from the default INF file location, %SystemRoot%\inf.
+ ///
+ ///
+ /// After this function has built the specified driver list, the caller can enumerate the elements of the list by calling SetupDiEnumDriverInfo.
+ ///
+ ///
+ /// If the driver list is associated with a device instance (that is, DeviceInfoData is specified), the resulting list is composed
+ /// of drivers that have the same class as the device instance with which they are associated. If this is a global class driver list
+ /// (that is, DriverType is SPDIT_CLASSDRIVER and DeviceInfoData is not specified), the class that is used when building the
+ /// list is the class associated with the device information set. If the device information set has no associated class, drivers of
+ /// all classes are used when building the list.
+ ///
+ /// Another thread can terminate the building of a driver list by a call to SetupDiCancelDriverInfoSearch.
+ /// The DeviceInfoSet must only contain elements on the local computer. This function only searches for local drivers.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdibuilddriverinfolist WINSETUPAPI BOOL
+ // SetupDiBuildDriverInfoList( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildDriverInfoList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiBuildDriverInfoList(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, SPDIT DriverType);
+
+ ///
+ /// The SetupDiCallClassInstaller function calls the appropriate class installer, and any registered co-installers, with the
+ /// specified installation request (DIF code).
+ ///
+ ///
+ ///
+ /// The device installation request (DIF request) to pass to the co-installers and class installer. DIF codes have the format
+ /// DIF_XXX and are defined in Setupapi.h. See Device Installation Function Codes for more information.
+ ///
+ ///
+ /// Note For certain DIF requests, the caller must be a member of the Administrators group. For such DIF requests, this
+ /// requirement is listed on the reference page for the associated default handler.
+ ///
+ ///
+ ///
+ /// A handle to a device information set for the local computer. This set contains a device installation element which represents
+ /// the device for which to perform the specified installation function.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in the DeviceInfoSet that represents the
+ /// device for which to perform the specified installation function. This parameter is optional and can be set to NULL. If
+ /// this parameter is specified, SetupDiCallClassInstaller performs the specified function on the DeviceInfoData element. If
+ /// DeviceInfoData is NULL, SetupDiCallClassInstaller calls the installers for the setup class that is associated with DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// When GetLastError returns ERROR_IN_WOW64, this means that the calling application is a 32-bit application attempting to
+ /// execute in a 64-bit environment, which is not allowed.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiCallClassInstaller calls the class installer and any co-installers that are registered for a device or a device
+ /// setup class. This function loads the installers if they are not yet loaded. The function also calls the default handler for the
+ /// DIF request, if there is a default handler and if the installers return a status indicating that the default handler should be called.
+ ///
+ ///
+ /// Device installation applications call this function with a variety of device installation function codes (DIF codes). The
+ /// function ensures that all the appropriate installers and default handlers are called, in the correct order, for a given DIF
+ /// request. For more information, see Handling DIF Codes.
+ ///
+ ///
+ /// After SetupDiCallClassInstaller returns TRUE, the device installation application must call
+ /// SetupDiGetDeviceInstallParams to obtain an SP_DEVINSTALL_PARAMS structure. If the structure's DI_NEEDREBOOT or
+ /// DI_NEEDRESTART flag is set, the caller must prompt the user to restart the system. For example, the caller can do this by
+ /// calling SetupPromptReboot.
+ ///
+ ///
+ /// However, be aware that a device installation application should request a system restart one time at most. Therefore, any device
+ /// installation application that creates multiple calls to SetupDiCallClassInstaller and SetupDiGetDeviceInstallParams
+ /// should save the DI_NEEDREBOOT and DI_NEEDRESTART flags after each call. However, it should prompt the user only
+ /// after the last call returns.
+ ///
+ ///
+ /// In response to a DIF code supplied by SetupDiCallClassInstaller, class installers and co-installers might perform
+ /// operations that require the system to be restarted. In such situations, the installer or co-installer should do the following:
+ ///
+ ///
+ /// -
+ /// Call SetupDiGetDeviceInstallParams to obtain the SP_DEVINSTALL_PARAMS structure.
+ ///
+ /// -
+ /// Set the DI_NEEDREBOOT or DI_NEEDRESTART flag in the structure's Flags member.
+ ///
+ /// -
+ /// Call SetupDiSetDeviceInstallParams, supplying the updated SP_DEVINSTALL_PARAMS structure, to save the revised Flags member.
+ ///
+ ///
+ ///
+ /// After SetupDiCallClassInstaller returns, the device installation application that called it should call
+ /// SetupDiGetDeviceInstallParams, check the flags, and request a restart if necessary.
+ ///
+ /// The device information set specified by DeviceInfoSet must only contain elements for devices on the local computer.
+ /// For information about the design and operation of co-installers, see Writing a Co-installer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicallclassinstaller WINSETUPAPI BOOL
+ // SetupDiCallClassInstaller( DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCallClassInstaller")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCallClassInstaller(DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiCallClassInstaller function calls the appropriate class installer, and any registered co-installers, with the
+ /// specified installation request (DIF code).
+ ///
+ ///
+ ///
+ /// The device installation request (DIF request) to pass to the co-installers and class installer. DIF codes have the format
+ /// DIF_XXX and are defined in Setupapi.h. See Device Installation Function Codes for more information.
+ ///
+ ///
+ /// Note For certain DIF requests, the caller must be a member of the Administrators group. For such DIF requests, this
+ /// requirement is listed on the reference page for the associated default handler.
+ ///
+ ///
+ ///
+ /// A handle to a device information set for the local computer. This set contains a device installation element which represents
+ /// the device for which to perform the specified installation function.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in the DeviceInfoSet that represents the
+ /// device for which to perform the specified installation function. This parameter is optional and can be set to NULL. If
+ /// this parameter is specified, SetupDiCallClassInstaller performs the specified function on the DeviceInfoData element. If
+ /// DeviceInfoData is NULL, SetupDiCallClassInstaller calls the installers for the setup class that is associated with DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// When GetLastError returns ERROR_IN_WOW64, this means that the calling application is a 32-bit application attempting to
+ /// execute in a 64-bit environment, which is not allowed.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiCallClassInstaller calls the class installer and any co-installers that are registered for a device or a device
+ /// setup class. This function loads the installers if they are not yet loaded. The function also calls the default handler for the
+ /// DIF request, if there is a default handler and if the installers return a status indicating that the default handler should be called.
+ ///
+ ///
+ /// Device installation applications call this function with a variety of device installation function codes (DIF codes). The
+ /// function ensures that all the appropriate installers and default handlers are called, in the correct order, for a given DIF
+ /// request. For more information, see Handling DIF Codes.
+ ///
+ ///
+ /// After SetupDiCallClassInstaller returns TRUE, the device installation application must call
+ /// SetupDiGetDeviceInstallParams to obtain an SP_DEVINSTALL_PARAMS structure. If the structure's DI_NEEDREBOOT or
+ /// DI_NEEDRESTART flag is set, the caller must prompt the user to restart the system. For example, the caller can do this by
+ /// calling SetupPromptReboot.
+ ///
+ ///
+ /// However, be aware that a device installation application should request a system restart one time at most. Therefore, any device
+ /// installation application that creates multiple calls to SetupDiCallClassInstaller and SetupDiGetDeviceInstallParams
+ /// should save the DI_NEEDREBOOT and DI_NEEDRESTART flags after each call. However, it should prompt the user only
+ /// after the last call returns.
+ ///
+ ///
+ /// In response to a DIF code supplied by SetupDiCallClassInstaller, class installers and co-installers might perform
+ /// operations that require the system to be restarted. In such situations, the installer or co-installer should do the following:
+ ///
+ ///
+ /// -
+ /// Call SetupDiGetDeviceInstallParams to obtain the SP_DEVINSTALL_PARAMS structure.
+ ///
+ /// -
+ /// Set the DI_NEEDREBOOT or DI_NEEDRESTART flag in the structure's Flags member.
+ ///
+ /// -
+ /// Call SetupDiSetDeviceInstallParams, supplying the updated SP_DEVINSTALL_PARAMS structure, to save the revised Flags member.
+ ///
+ ///
+ ///
+ /// After SetupDiCallClassInstaller returns, the device installation application that called it should call
+ /// SetupDiGetDeviceInstallParams, check the flags, and request a restart if necessary.
+ ///
+ /// The device information set specified by DeviceInfoSet must only contain elements for devices on the local computer.
+ /// For information about the design and operation of co-installers, see Writing a Co-installer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicallclassinstaller WINSETUPAPI BOOL
+ // SetupDiCallClassInstaller( DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCallClassInstaller")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCallClassInstaller(DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
+
+ ///
+ /// The SetupDiCancelDriverInfoSearch function cancels a driver list search that is currently in progress in a different thread.
+ ///
+ /// A handle to the device information set for which a driver list is being built.
+ ///
+ /// If a driver list search is underway for the specified device information set when this function is called, the search is
+ /// terminated. SetupDiCancelDriverInfoSearch returns TRUE when the termination is confirmed. Otherwise, it returns
+ /// FALSE and a call to GetLastError returns ERROR_INVALID_HANDLE.
+ ///
+ ///
+ /// SetupDiCancelDriverInfoSearch is a synchronous call. Therefore, it does not return until the driver search thread
+ /// responds to the termination request.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicanceldriverinfosearch WINSETUPAPI BOOL
+ // SetupDiCancelDriverInfoSearch( HDEVINFO DeviceInfoSet );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCancelDriverInfoSearch")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCancelDriverInfoSearch(HDEVINFO DeviceInfoSet);
+
+ /// The SetupDiChangeState function is the default handler for the DIF_PROPERTYCHANGE installation request.
+ ///
+ /// A handle to a device information set for the local computer. This set contains a device information element that represents the
+ /// device whose state is to be changed.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoData. DevInst might be updated with a new handle value upon return.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// SetupDiChangeState changes the state of an installed device.
+ /// The caller of SetupDiChangeState must be a member of the Administrators group.
+ ///
+ /// Note Only a class installer should call SetupDiChangeState and only in those situations where the class installer
+ /// must perform property change operations after SetupDiChangeState completes the default property change operation. In such
+ /// situations, the class installer must directly call SetupDiChangeState when the installer processes a DIF_PROPERTYCHANGE
+ /// request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ /// Callers of SetupDiChangeState must specify a DICS_XXX flag in the SP_PROPCHANGE_PARAMS for the device element that
+ /// indicates the type of state change to perform on the device. Callers of this function must set the appropriate fields in the
+ /// SP_PROPCHANGE_PARAMS and call SetupDiSetClassInstallParams before calling this function.
+ ///
+ ///
+ /// If you specify the DICS_FLAG_CONFIGSPECIFIC flag in the SP_PROPCHANGE_PARAMS then you must fill in the HwProfile field. A
+ /// value of zero for HwProfile indicates the current profile.
+ ///
+ ///
+ /// To enable/disable a device in the current hardware profile, set the DICS_FLAG_CONFIGSPECIFIC flag in the SP_PROPCHANGE_PARAMS.
+ /// To enable/disable a device globally, such as in both the docked and undocked hardware profiles, set the DICS_FLAG_GLOBAL flag.
+ ///
+ /// This function does the following:
+ ///
+ /// Callers of this function should not specify DICS_STOP or DICS_START in the SP_PROPCHANGE_PARAMS. Use DICS_PROPCHANGE to stop and
+ /// restart a device to cause changes in the device's configuration to take effect.
+ ///
+ ///
+ /// If DI_DONOTCALLCONFIGMG is set for a device, you should not call SetupDiChangeState for the device but should instead set
+ /// the DI_NEEDREBOOT flag.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdichangestate WINSETUPAPI BOOL SetupDiChangeState(
+ // HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiChangeState")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiChangeState(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiClassGuidsFromName function retrieves the GUID(s) associated with the specified class name. This list is built
+ /// based on the classes currently installed on the system.
+ ///
+ /// The name of the class for which to retrieve the class GUID.
+ /// A pointer to an array to receive the list of GUIDs associated with the specified class name.
+ /// The number of GUIDs in the ClassGuidList array.
+ ///
+ /// Supplies a pointer to a variable that receives the number of GUIDs associated with the class name. If this number is greater
+ /// than the size of the ClassGuidList buffer, the number indicates how large the array must be in order to store all the GUIDs.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ /// Call SetupDiClassGuidsFromNameEx to retrieve the class GUIDs for a class on a remote computer.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiclassguidsfromnamea WINSETUPAPI BOOL
+ // SetupDiClassGuidsFromNameA( PCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiClassGuidsFromNameA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiClassGuidsFromName(string ClassName,
+ [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] ClassGuidList, uint ClassGuidListSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiClassGuidsFromNameEx function retrieves the GUIDs associated with the specified class name. This resulting
+ /// list contains the classes currently installed on a local or remote computer.
+ ///
+ /// The name of the class for which to retrieve the class GUIDs.
+ /// A pointer to an array to receive the list of GUIDs associated with the specified class name.
+ /// The number of GUIDs in the ClassGuidList array.
+ ///
+ /// A pointer to a variable that receives the number of GUIDs associated with the class name. If this number is greater than the
+ /// size of the ClassGuidList buffer, the number indicates how large the array must be in order to store all the GUIDs.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote system from which to retrieve the GUIDs. This parameter
+ /// is optional and can be NULL. If MachineName is NULL, the local system name is used.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// Class names are not guaranteed to be unique; only GUIDs are unique. Therefore, one class name can return more than one GUID.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiclassguidsfromnameexa WINSETUPAPI BOOL
+ // SetupDiClassGuidsFromNameExA( PCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCSTR
+ // MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiClassGuidsFromNameExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiClassGuidsFromNameEx(string ClassName,
+ [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] ClassGuidList, uint ClassGuidListSize, out uint RequiredSize,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, IntPtr Reserved = default);
+
/// The SetupDiClassNameFromGuid function retrieves the class name associated with a class GUID.
/// A pointer to the class GUID for the class name to retrieve.
///
@@ -61,6 +725,723 @@ namespace Vanara.PInvoke
public static bool SetupDiClassNameFromGuid(Guid ClassGuid, out string ClassName) =>
FunctionHelper.CallMethodWithStrBuf((StringBuilder sb, ref uint sz) => SetupDiClassNameFromGuid(ClassGuid, sb, sz, out sz), out ClassName);
+ ///
+ /// The SetupDiClassNameFromGuidEx function retrieves the class name associated with a class GUID. The class can be installed
+ /// on a local or remote computer.
+ ///
+ /// The class GUID of the class name to retrieve.
+ ///
+ /// A pointer to a string buffer that receives the NULL-terminated name of the class for the specified GUID.
+ ///
+ /// The size, in characters, of the ClassName buffer.
+ ///
+ /// The number of characters required to store the class name (including a terminating null). RequiredSize is always less than MAX_CLASS_NAME_LEN.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote system on which the class is installed. This parameter
+ /// is optional and can be NULL. If MachineName is NULL, the local system name is used.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiclassnamefromguidexa WINSETUPAPI BOOL
+ // SetupDiClassNameFromGuidExA( const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName,
+ // PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiClassNameFromGuidExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiClassNameFromGuidEx(in Guid ClassGuid, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ClassName,
+ uint ClassNameSize, out uint RequiredSize, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, IntPtr Reserved = default);
+
+ ///
+ /// The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the
+ /// specified device information set.
+ ///
+ /// A handle to the device information set for the local computer.
+ ///
+ /// A pointer to a NULL-terminated string that supplies either a full device instance ID (for example, "Root*PNP0500\0000") or a
+ /// root-enumerated device ID without the enumerator prefix and instance identifier suffix (for example, "*PNP0500"). The
+ /// root-enumerated device identifier can be used only if the DICD_GENERATE_ID flag is specified in the CreationFlags parameter.
+ ///
+ ///
+ /// A pointer to the device setup class GUID for the device. If the device setup class of the device is not known, set *ClassGuid to
+ /// a GUID_NULL structure.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that supplies the text description of the device. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to installing the device. This handle is optional
+ /// and can be NULL.
+ ///
+ ///
+ ///
+ /// A variable of type DWORD that controls how the device information element is created. Can be a combination of the following values:
+ ///
+ /// DICD_GENERATE_ID
+ ///
+ /// If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a full
+ /// device instance ID for the new device information element.
+ ///
+ ///
+ /// Call SetupDiGetDeviceInstanceId to retrieve the device instance ID that was generated for this device information element.
+ ///
+ /// DICD_INHERIT_CLASSDRVS
+ ///
+ /// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with the
+ /// device information set. In addition, if there is a selected driver for the device information set, that same driver is selected
+ /// for the new device information element.
+ ///
+ ///
+ ///
+ /// A pointer to a SP_DEVINFO_DATA structure that receives the new device information element. This pointer is optional and can be
+ /// NULL. If the structure is supplied, the caller must set the cbSize member of this structure to sizeof(
+ /// SP_DEVINFO_DATA ) before calling the function. For more information, see the following Remarks section.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// If this device instance is being added to a set that has an associated class, the device class must be the same or the call
+ /// fails. In this case, a call to GetLastError returns ERROR_CLASS_MISMATCH.
+ ///
+ ///
+ /// If the specified device instance is the same as an existing device instance key in the registry, the call fails. In this case, a
+ /// call to GetLastError returns ERROR_DEVINST_ALREADY_EXISTS. This occurs only if the DICD_GENERATE_ID flag is not set.
+ ///
+ ///
+ /// If the new device information element was successfully created but the caller-supplied DeviceInfoData buffer is invalid, the
+ /// function returns FALSE. In this case, a call to GetLastError returns ERROR_INVALID_USER_BUFFER. However, the device
+ /// information element will have been added as a new member of the set already.
+ ///
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfoa WINSETUPAPI BOOL
+ // SetupDiCreateDeviceInfoA( HDEVINFO DeviceInfoSet, PCSTR DeviceName, const GUID *ClassGuid, PCSTR DeviceDescription, HWND
+ // hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCreateDeviceInfo(HDEVINFO DeviceInfoSet, [In, MarshalAs(UnmanagedType.LPTStr)] string DeviceName,
+ in Guid ClassGuid, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string DeviceDescription, [In, Optional] HWND hwndParent,
+ DICD CreationFlags, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the
+ /// specified device information set.
+ ///
+ /// A handle to the device information set for the local computer.
+ ///
+ /// A pointer to a NULL-terminated string that supplies either a full device instance ID (for example, "Root*PNP0500\0000") or a
+ /// root-enumerated device ID without the enumerator prefix and instance identifier suffix (for example, "*PNP0500"). The
+ /// root-enumerated device identifier can be used only if the DICD_GENERATE_ID flag is specified in the CreationFlags parameter.
+ ///
+ ///
+ /// A pointer to the device setup class GUID for the device. If the device setup class of the device is not known, set *ClassGuid to
+ /// a GUID_NULL structure.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that supplies the text description of the device. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to installing the device. This handle is optional
+ /// and can be NULL.
+ ///
+ ///
+ ///
+ /// A variable of type DWORD that controls how the device information element is created. Can be a combination of the following values:
+ ///
+ /// DICD_GENERATE_ID
+ ///
+ /// If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a full
+ /// device instance ID for the new device information element.
+ ///
+ ///
+ /// Call SetupDiGetDeviceInstanceId to retrieve the device instance ID that was generated for this device information element.
+ ///
+ /// DICD_INHERIT_CLASSDRVS
+ ///
+ /// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with the
+ /// device information set. In addition, if there is a selected driver for the device information set, that same driver is selected
+ /// for the new device information element.
+ ///
+ ///
+ ///
+ /// A pointer to a SP_DEVINFO_DATA structure that receives the new device information element. This pointer is optional and can be
+ /// NULL. If the structure is supplied, the caller must set the cbSize member of this structure to sizeof(
+ /// SP_DEVINFO_DATA ) before calling the function. For more information, see the following Remarks section.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// If this device instance is being added to a set that has an associated class, the device class must be the same or the call
+ /// fails. In this case, a call to GetLastError returns ERROR_CLASS_MISMATCH.
+ ///
+ ///
+ /// If the specified device instance is the same as an existing device instance key in the registry, the call fails. In this case, a
+ /// call to GetLastError returns ERROR_DEVINST_ALREADY_EXISTS. This occurs only if the DICD_GENERATE_ID flag is not set.
+ ///
+ ///
+ /// If the new device information element was successfully created but the caller-supplied DeviceInfoData buffer is invalid, the
+ /// function returns FALSE. In this case, a call to GetLastError returns ERROR_INVALID_USER_BUFFER. However, the device
+ /// information element will have been added as a new member of the set already.
+ ///
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfoa WINSETUPAPI BOOL
+ // SetupDiCreateDeviceInfoA( HDEVINFO DeviceInfoSet, PCSTR DeviceName, const GUID *ClassGuid, PCSTR DeviceDescription, HWND
+ // hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCreateDeviceInfo(HDEVINFO DeviceInfoSet, [In, MarshalAs(UnmanagedType.LPTStr)] string DeviceName,
+ in Guid ClassGuid, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string DeviceDescription, [In, Optional] HWND hwndParent,
+ DICD CreationFlags, IntPtr DeviceInfoData = default);
+
+ ///
+ /// The SetupDiCreateDeviceInfoList function creates an empty device information set and optionally associates the set with a
+ /// device setup class and a top-level window.
+ ///
+ ///
+ /// A pointer to the GUID of the device setup class to associate with the newly created device information set. If this
+ /// parameter is specified, only devices of this class can be included in this device information set. If this parameter is set to
+ /// NULL, the device information set is not associated with a specific device setup class.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a
+ /// select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific
+ /// top-level window is not required, set hwndParent to NULL.
+ ///
+ ///
+ /// The function returns a handle to an empty device information set if it is successful. Otherwise, it returns
+ /// INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ /// The caller of this function must delete the returned device information set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.
+ /// To create a device information list for a remote computer use SetupDiCreateDeviceInfoListEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfolist WINSETUPAPI HDEVINFO
+ // SetupDiCreateDeviceInfoList( const GUID *ClassGuid, HWND hwndParent );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoList")]
+ public static extern SafeHDEVINFO SetupDiCreateDeviceInfoList(in Guid ClassGuid, [In, Optional] HWND hwndParent);
+
+ ///
+ /// The SetupDiCreateDeviceInfoList function creates an empty device information set and optionally associates the set with a
+ /// device setup class and a top-level window.
+ ///
+ ///
+ /// A pointer to the GUID of the device setup class to associate with the newly created device information set. If this
+ /// parameter is specified, only devices of this class can be included in this device information set. If this parameter is set to
+ /// NULL, the device information set is not associated with a specific device setup class.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a
+ /// select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific
+ /// top-level window is not required, set hwndParent to NULL.
+ ///
+ ///
+ /// The function returns a handle to an empty device information set if it is successful. Otherwise, it returns
+ /// INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ /// The caller of this function must delete the returned device information set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.
+ /// To create a device information list for a remote computer use SetupDiCreateDeviceInfoListEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfolist WINSETUPAPI HDEVINFO
+ // SetupDiCreateDeviceInfoList( const GUID *ClassGuid, HWND hwndParent );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoList")]
+ public static extern SafeHDEVINFO SetupDiCreateDeviceInfoList([In, Optional] IntPtr ClassGuid, [In, Optional] HWND hwndParent);
+
+ ///
+ /// The SetupDiCreateDeviceInfoList function creates an empty device information set on a remote or a local computer and
+ /// optionally associates the set with a device setup class .
+ ///
+ ///
+ /// A pointer to the GUID of the device setup class to associate with the newly created device information set. If this parameter is
+ /// specified, only devices of this class can be included in this device information set. If this parameter is set to NULL,
+ /// the device information set is not associated with a specific device setup class.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a
+ /// select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific
+ /// top-level window is not required, set hwndParent to NULL.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a computer on a network. If a name is specified, only devices on
+ /// that computer can be created and opened in this device information set. If this parameter is set to NULL, the device
+ /// information set is for devices on the local computer.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns a handle to an empty device information set if it is successful. Otherwise, it returns
+ /// INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ /// The caller of this function must delete the returned device information set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.
+ ///
+ /// If the device information set is for devices on a remote computer (MachineName is not NULL), all subsequent operations on
+ /// this set or any of its elements must use routines that support device information sets with remote elements. The SetupDi
+ /// Xxx routines that do not provide this support, such as SetupDiCallClassInstaller, have a statement to that effect in their
+ /// reference page.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfolistexa WINSETUPAPI HDEVINFO
+ // SetupDiCreateDeviceInfoListExA( const GUID *ClassGuid, HWND hwndParent, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoListExA")]
+ public static extern SafeHDEVINFO SetupDiCreateDeviceInfoListEx(in Guid ClassGuid, [In, Optional] HWND hwndParent,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiCreateDeviceInfoList function creates an empty device information set on a remote or a local computer and
+ /// optionally associates the set with a device setup class .
+ ///
+ ///
+ /// A pointer to the GUID of the device setup class to associate with the newly created device information set. If this parameter is
+ /// specified, only devices of this class can be included in this device information set. If this parameter is set to NULL,
+ /// the device information set is not associated with a specific device setup class.
+ ///
+ ///
+ /// A handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a
+ /// select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific
+ /// top-level window is not required, set hwndParent to NULL.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a computer on a network. If a name is specified, only devices on
+ /// that computer can be created and opened in this device information set. If this parameter is set to NULL, the device
+ /// information set is for devices on the local computer.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns a handle to an empty device information set if it is successful. Otherwise, it returns
+ /// INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ /// The caller of this function must delete the returned device information set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.
+ ///
+ /// If the device information set is for devices on a remote computer (MachineName is not NULL), all subsequent operations on
+ /// this set or any of its elements must use routines that support device information sets with remote elements. The SetupDi
+ /// Xxx routines that do not provide this support, such as SetupDiCallClassInstaller, have a statement to that effect in their
+ /// reference page.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinfolistexa WINSETUPAPI HDEVINFO
+ // SetupDiCreateDeviceInfoListExA( const GUID *ClassGuid, HWND hwndParent, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoListExA")]
+ public static extern SafeHDEVINFO SetupDiCreateDeviceInfoListEx([In, Optional] IntPtr ClassGuid, [In, Optional] HWND hwndParent,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiCreateDeviceInterface function registers a device interface on a local system or a remote system.
+ ///
+ /// A handle to a device information set. This set contains a device information element that represents the device for which to
+ /// register an interface. This handle is typically returned by SetupDiGetClassDevs.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ /// A pointer to a class GUID that specifies the interface class for the new interface.
+ ///
+ /// A pointer to a NULL-terminated string that supplies a reference string. This pointer is optional and can be NULL.
+ /// Reference strings are used only by a few bus drivers that use device interfaces as placeholders for software devices that are
+ /// created on demand.
+ ///
+ /// Reserved. Must be zero.
+ ///
+ /// A pointer to a caller-initialized SP_DEVICE_INTERFACE_DATA structure to receive information about the new device interface. This
+ /// pointer is optional and can be NULL. If the structure is supplied, the caller must set the cbSize member of this
+ /// structure to sizeof( SP_DEVICE_INTERFACE_DATA ) before calling this function. For more information, see the
+ /// following Remarks section.
+ ///
+ ///
+ /// SetupDiCreateDeviceInterface returns TRUE if the function completed without error. If the function completed with
+ /// an error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiCreateDeviceInterface registers an interface for a device. If a device has more than one interface, call this
+ /// function once for each interface being registered.
+ ///
+ ///
+ /// If this function successfully registers an interface for the device that corresponds to the specified device information
+ /// element, it also adds the interface to the interface list that is associated with the device information element in the
+ /// specified device information set.
+ ///
+ ///
+ /// Before a registered interface can be used by applications and other system components the interface must be enabled by the
+ /// driver for the device.
+ ///
+ ///
+ /// This function creates a registry key for the new device interface. Callers of this function can access nonvolatile storage under
+ /// this key using SetupDiOpenDeviceInterfaceRegKey.
+ ///
+ ///
+ /// If SetupDiCreateDeviceInterface successfully creates a new device interface, but the caller-supplied buffer in the
+ /// DeviceInterfaceData parameter is invalid, this function will return FALSE and a subsequent call to GetLastError will
+ /// return ERROR_INVALID_USER_BUFFER. However, the function does create and register the new device interface.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinterfacea WINSETUPAPI BOOL
+ // SetupDiCreateDeviceInterfaceA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const GUID *InterfaceClassGuid, PCSTR
+ // ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInterfaceA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCreateDeviceInterface(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in Guid InterfaceClassGuid,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string ReferenceString, [In, Optional] uint CreationFlags,
+ ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
+
+ /// The SetupDiCreateDeviceInterface function registers a device interface on a local system or a remote system.
+ ///
+ /// A handle to a device information set. This set contains a device information element that represents the device for which to
+ /// register an interface. This handle is typically returned by SetupDiGetClassDevs.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ /// A pointer to a class GUID that specifies the interface class for the new interface.
+ ///
+ /// A pointer to a NULL-terminated string that supplies a reference string. This pointer is optional and can be NULL.
+ /// Reference strings are used only by a few bus drivers that use device interfaces as placeholders for software devices that are
+ /// created on demand.
+ ///
+ /// Reserved. Must be zero.
+ ///
+ /// A pointer to a caller-initialized SP_DEVICE_INTERFACE_DATA structure to receive information about the new device interface. This
+ /// pointer is optional and can be NULL. If the structure is supplied, the caller must set the cbSize member of this
+ /// structure to sizeof( SP_DEVICE_INTERFACE_DATA ) before calling this function. For more information, see the
+ /// following Remarks section.
+ ///
+ ///
+ /// SetupDiCreateDeviceInterface returns TRUE if the function completed without error. If the function completed with
+ /// an error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiCreateDeviceInterface registers an interface for a device. If a device has more than one interface, call this
+ /// function once for each interface being registered.
+ ///
+ ///
+ /// If this function successfully registers an interface for the device that corresponds to the specified device information
+ /// element, it also adds the interface to the interface list that is associated with the device information element in the
+ /// specified device information set.
+ ///
+ ///
+ /// Before a registered interface can be used by applications and other system components the interface must be enabled by the
+ /// driver for the device.
+ ///
+ ///
+ /// This function creates a registry key for the new device interface. Callers of this function can access nonvolatile storage under
+ /// this key using SetupDiOpenDeviceInterfaceRegKey.
+ ///
+ ///
+ /// If SetupDiCreateDeviceInterface successfully creates a new device interface, but the caller-supplied buffer in the
+ /// DeviceInterfaceData parameter is invalid, this function will return FALSE and a subsequent call to GetLastError will
+ /// return ERROR_INVALID_USER_BUFFER. However, the function does create and register the new device interface.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinterfacea WINSETUPAPI BOOL
+ // SetupDiCreateDeviceInterfaceA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const GUID *InterfaceClassGuid, PCSTR
+ // ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInterfaceA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiCreateDeviceInterface(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in Guid InterfaceClassGuid,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string ReferenceString, uint CreationFlags = 0, IntPtr DeviceInterfaceData = default);
+
+ ///
+ /// The SetupDiCreateDeviceInterfaceRegKey function creates a registry key for storing information about a device interface
+ /// and returns a handle to the key.
+ ///
+ ///
+ /// A handle to a device information set that contains the interface for which to create a registry key. The device information set
+ /// must not contain remote elements.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet. This pointer is
+ /// possibly returned by SetupDiCreateDeviceInterface.
+ ///
+ /// Reserved. Must be zero.
+ ///
+ /// The registry security access that the caller requests for the key that is being created. For information about registry security
+ /// access values of type REGSAM, see the Microsoft Windows SDK documentation.
+ ///
+ ///
+ /// The handle to an open INF file that contains a DDInstall section to be executed for the newly-created key. This parameter is
+ /// optional and can be NULL. If this parameter is not NULL, InfSectionName must be specified as well.
+ ///
+ ///
+ /// A pointer to the name of an INF DDInstall section in the INF file that is specified by InfHandle. This section is executed for
+ /// the newly created key. This parameter is optional and can be NULL. If this parameter is specified, InfHandle must be
+ /// specified as well.
+ ///
+ ///
+ /// If SetupDiCreateDeviceInterfaceRegKey succeeds, the function returns a handle to the requested registry key in which
+ /// interface information can be stored and retrieved. If SetupDiCreateDeviceInterfaceRegKey fails, the function returns
+ /// INVALID_HANDLE_VALUE. Call GetLastError to get extended error information.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// If the requested key for the device interface already exists, SetupDiCreateDeviceInterfaceRegKey returns a handle to that
+ /// key; otherwise, SetupDiCreateDeviceInterfaceRegKey creates a new nonvolatile registry key for the specified device
+ /// interface. Callers of this function can store private configuration data for the device interface in this key. The driver for
+ /// the device can access this key using Io Xxx routines.
+ ///
+ /// Close the handle returned from this function by calling RegCloseKey.
+ ///
+ /// For installations that use layout files (specified by the LayoutFile entry in an INF Version section), the layout file
+ /// must be opened by a call to SetupOpenAppendInfFile (described in Windows SDK documentation) before
+ /// SetupDiCreateDeviceInterfaceRegKey is called.
+ ///
+ /// The device information set specified by DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedeviceinterfaceregkeya WINSETUPAPI HKEY
+ // SetupDiCreateDeviceInterfaceRegKeyA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved,
+ // REGSAM samDesired, HINF InfHandle, PCSTR InfSectionName );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInterfaceRegKeyA")]
+ public static extern HKEY SetupDiCreateDeviceInterfaceRegKey(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [Optional] uint Reserved, System.Security.AccessControl.RegistryRights samDesired, [In, Optional] HINF InfHandle, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string InfSectionName);
+
+ ///
+ /// The SetupDiCreateDevRegKey function creates a registry key for device-specific configuration information and returns a
+ /// handle to the key.
+ ///
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to create a
+ /// registry key.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ ///
+ /// The scope of the registry key to be created. The scope determines where the information is stored. The key created can be global
+ /// or hardware profile-specific. Can be one of the following values:
+ ///
+ /// DICS_FLAG_GLOBAL
+ ///
+ /// Create a key to store global configuration information. This information is not specific to a particular hardware profile. On
+ /// NT-based operating systems this creates a key that is rooted at HKEY_LOCAL_MACHINE. The exact key opened depends on the
+ /// value of the KeyType parameter.
+ ///
+ /// DICS_FLAG_CONFIGSPECIFIC
+ ///
+ /// Create a key to store hardware profile-specific configuration information. This key is rooted at one of the hardware-profile
+ /// specific branches, instead of HKEY_LOCAL_MACHINE.
+ ///
+ ///
+ ///
+ /// The hardware profile for which to create a key if HwProfileFlags is set to SPDICS_FLAG_CONFIGSPECIFIC. If HwProfile is 0, the
+ /// key for the current hardware profile is created. If HwProfileFlags is SPDICS_FLAG_GLOBAL, HwProfile is ignored.
+ ///
+ ///
+ /// The type of registry storage key to create. Can be one of the following values:
+ /// DIREG_DEV
+ /// Create a hardware key for the device.
+ /// DIREG_DRV
+ /// Create a software key for the device.
+ ///
+ ///
+ /// The handle to an open INF file that contains an INF DDInstall section to be executed for the newly created key. This parameter
+ /// is optional and can be NULL. If this parameter is specified, InfSectionName must be specified as well.
+ ///
+ ///
+ /// The name of an INF DDInstall section in the INF file specified by InfHandle. This section is executed for the newly created key.
+ /// This parameter is optional and can be NULL. If this parameter is specified, InfHandle must be specified as well.
+ ///
+ ///
+ /// If SetupDiCreateDevRegKey succeeds, the function returns a handle to the specified registry key in which device-specific
+ /// configuration data can be stored and retrieved. If SetupDiCreateDevRegKey fails, the function returns
+ /// INVALID_HANDLE_VALUE. Call GetLastError to get extended error information.
+ ///
+ ///
+ /// The caller of SetupDiCreateDevRegKey must be a member of the Administrators group.
+ /// Close the handle returned from SetupDiCreateDevRegKey by calling RegCloseKey.
+ ///
+ /// If the specified key already exists, SetupDiCreateDevRegKey returns a handle to that key. Otherwise,
+ /// SetupDiCreateDevRegKey creates the specified key and returns a handle to the new key. For Windows Server 2003 and later
+ /// versions of Windows, the key handle has KEY_READ and KEY_WRITE access only. For previous Windows versions, this handle has
+ /// KEY_ALL_ACCESS access.
+ ///
+ ///
+ /// The specified device instance must be registered before SetupDiCreateDevRegKey is called. Note, however, that the
+ /// operating system automatically registers PnP device instances. For information about how to register non-PnP device instances,
+ /// see SetupDiRegisterDeviceInfo.
+ ///
+ ///
+ /// For installations that use layout files (specified by the LayoutFile entry in an INF Version section), the layout file
+ /// must be opened by a call to SetupOpenAppendInfFile (described in the Microsoft Windows SDK documentation) before
+ /// SetupDiCreateDevRegKey is called.
+ ///
+ ///
+ /// If the supplied device information set contains device information elements for a remote system, and InfHandle and
+ /// InfSectionName are also specified, the create request will fail, and a subsequent call to GetLastError will return ERROR_REMOTE_REQUEST_UNSUPPORTED.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdicreatedevregkeya WINSETUPAPI HKEY
+ // SetupDiCreateDevRegKeyA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType,
+ // HINF InfHandle, PCSTR InfSectionName );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDevRegKeyA")]
+ public static extern HKEY SetupDiCreateDevRegKey(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, DICS_FLAG Scope,
+ uint HwProfile, DIREG KeyType, [In, Optional] HINF InfHandle, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string InfSectionName);
+
+ ///
+ /// The SetupDiDeleteDeviceInfo function deletes a device information element from a device information set. This function
+ /// does not delete the actual device.
+ ///
+ /// A handle to the device information set that contains the device information element to delete.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that represents the device information element in DeviceInfoSet to delete.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// If the specified device information element is in use (for example, by a wizard page), the function fails. In this case, a call
+ /// to GetLastError returns ERROR_DEVINFO_DATA_LOCKED. This happens if a handle to a wizard page is retrieved with a call to
+ /// SetupDiGetWizardPage with this device information element specified and the DIWP_FLAG_USE_DEVINFO_DATA flag set. To delete this
+ /// device information element, you must first close the wizard's HPROPSHEETPAGE handle.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdideletedeviceinfo WINSETUPAPI BOOL
+ // SetupDiDeleteDeviceInfo( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDeleteDeviceInfo")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDeleteDeviceInfo(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiDeleteDeviceInterfaceData function deletes a device interface from a device information set.
+ ///
+ /// A pointer to the device information set that contains the interface to delete. This handle is typically returned by SetupDiGetClassDevs.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet to delete. This structure is
+ /// typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ ///
+ /// SetupDiDeleteDeviceInterfaceData returns TRUE if the function completed without error. If the function completed
+ /// with an error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// SetupDiDeleteDeviceInterfaceData deletes a device interface element from a device information set. This function has no
+ /// effect on the device interface or the underlying device.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdideletedeviceinterfacedata WINSETUPAPI BOOL
+ // SetupDiDeleteDeviceInterfaceData( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDeleteDeviceInterfaceData")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDeleteDeviceInterfaceData(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
+
+ ///
+ /// The SetupDiDeleteDeviceInterfaceRegKey function deletes the registry subkey that is used by applications and drivers to
+ /// store interface-specific information.
+ ///
+ ///
+ /// A pointer to a device information set that contains the interface for which to delete interface-specific information in the
+ /// registry. The device information set must not contain remote elements.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet. This pointer is
+ /// possibly returned by SetupDiCreateDeviceInterface or SetupDiEnumDeviceInterfaces.
+ ///
+ /// Reserved. Must be zero.
+ ///
+ /// SetupDiDeleteDeviceInterfaceRegKey returns TRUE if it is successful; otherwise, it returns FALSE and the
+ /// logged error can be retrieved with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiDeleteDeviceInterfaceRegKey deletes the subkey used by drivers and applications to store information about the
+ /// device interface instance. This subkey was created by SetupDiCreateDeviceInterfaceRegKey or by the driver's call to an
+ /// associated I/O manager routine. SetupDiDeleteDeviceInterfaceRegKey does not affect the main registry key for the device
+ /// interface instance nor any other subkeys that may have been created.
+ ///
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdideletedeviceinterfaceregkey WINSETUPAPI BOOL
+ // SetupDiDeleteDeviceInterfaceRegKey( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDeleteDeviceInterfaceRegKey")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, uint Reserved = 0);
+
+ ///
+ /// The SetupDiDeleteDevRegKey function deletes specified user-accessible registry keys that are associated with a device
+ /// information element.
+ ///
+ ///
+ /// A handle to the device information set that contains a device information element that represents the device for which to delete
+ /// registry keys. The device information set must not contain remote elements.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ ///
+ /// The scope of the registry key to delete. The scope indicates where the information is located. The key can be global or hardware
+ /// profile-specific. Can be one of the following values:
+ ///
+ /// DICS_FLAG_GLOBAL
+ /// Delete the key that stores global configuration information.
+ /// DICS_FLAG_CONFIGSPECIFIC
+ /// Delete the key that stores hardware profile-specific configuration information.
+ ///
+ ///
+ /// If Scope is set to DICS_FLAG_CONFIGSPECIFIC, the HwProfile parameter specifies the hardware profile for which to delete the
+ /// registry key. If HwProfile is 0, the key for the current hardware profile is deleted. If HwProfile is 0xFFFFFFFF, the registry
+ /// key for all hardware profiles is deleted.
+ ///
+ ///
+ /// The type of registry storage key to delete. Can be one of the following values:
+ /// DIREG_DEV
+ /// Delete the device's hardware key.
+ /// DIREG_DRV
+ /// Delete the device's software key.
+ /// DIREG_BOTH
+ /// Delete both the hardware and software keys for the device.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdideletedevregkey WINSETUPAPI BOOL
+ // SetupDiDeleteDevRegKey( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDeleteDevRegKey")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDeleteDevRegKey(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, DICS_FLAG Scope, uint HwProfile, DIREG KeyType);
+
+ ///
+ /// The SetupDiDestroyClassImageList function destroys a class image list that was built by a call to
+ /// SetupDiGetClassImageList or SetupDiGetClassImageListEx.
+ ///
+ /// A pointer to an SP_CLASSIMAGELIST_DATA structure that contains the class image list to destroy.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdidestroyclassimagelist WINSETUPAPI BOOL
+ // SetupDiDestroyClassImageList( PSP_CLASSIMAGELIST_DATA ClassImageListData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDestroyClassImageList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDestroyClassImageList(in SP_CLASSIMAGELIST_DATA ClassImageListData);
+
/// The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory.
/// A handle to the device information set to delete.
///
@@ -74,6 +1455,187 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet);
+ /// The SetupDiDestroyDriverInfoList function deletes a driver list.
+ /// A handle to a device information set that contains the driver list to delete.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiDestroyDriverInfoList deletes the driver
+ /// list for the specified device. If this parameter is NULL, SetupDiDestroyDriverInfoList deletes the global class
+ /// driver list that is associated with DeviceInfoSet.
+ ///
+ ///
+ /// The type of driver list to delete, which must be one of the following values:
+ /// SPDIT_CLASSDRIVER
+ /// Delete a list of class drivers. If DeviceInfoData is NULL, this driver list type must be specified.
+ /// SPDIT_COMPATDRIVER
+ ///
+ /// Delete a list of compatible drivers for the specified device. DeviceInfoData must be specified if this driver list type is specified.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// If the currently selected driver is a member of the list being deleted, the selection is reset.
+ ///
+ /// If a class driver list is being deleted, the DI_FLAGSEX_DIDINFOLIST and DI_DIDCLASS flags are reset for the corresponding device
+ /// information set or device information element. The DI_MULTMFGS flags is also reset.
+ ///
+ ///
+ /// If a compatible driver list is being destroyed, the DI_FLAGSEX_DIDCOMPATINFO and DI_DIDCOMPAT flags are reset for the
+ /// corresponding device information element.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdidestroydriverinfolist WINSETUPAPI BOOL
+ // SetupDiDestroyDriverInfoList( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDestroyDriverInfoList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDestroyDriverInfoList(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, SPDIT DriverType);
+
+ /// The SetupDiDestroyDriverInfoList function deletes a driver list.
+ /// A handle to a device information set that contains the driver list to delete.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiDestroyDriverInfoList deletes the driver
+ /// list for the specified device. If this parameter is NULL, SetupDiDestroyDriverInfoList deletes the global class
+ /// driver list that is associated with DeviceInfoSet.
+ ///
+ ///
+ /// The type of driver list to delete, which must be one of the following values:
+ /// SPDIT_CLASSDRIVER
+ /// Delete a list of class drivers. If DeviceInfoData is NULL, this driver list type must be specified.
+ /// SPDIT_COMPATDRIVER
+ ///
+ /// Delete a list of compatible drivers for the specified device. DeviceInfoData must be specified if this driver list type is specified.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// If the currently selected driver is a member of the list being deleted, the selection is reset.
+ ///
+ /// If a class driver list is being deleted, the DI_FLAGSEX_DIDINFOLIST and DI_DIDCLASS flags are reset for the corresponding device
+ /// information set or device information element. The DI_MULTMFGS flags is also reset.
+ ///
+ ///
+ /// If a compatible driver list is being destroyed, the DI_FLAGSEX_DIDCOMPATINFO and DI_DIDCOMPAT flags are reset for the
+ /// corresponding device information element.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdidestroydriverinfolist WINSETUPAPI BOOL
+ // SetupDiDestroyDriverInfoList( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDestroyDriverInfoList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiDestroyDriverInfoList(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, SPDIT DriverType);
+
+ /// The SetupDiDrawMiniIcon function draws the specified mini-icon at the location requested.
+ /// The handle to the device context in which the mini-icon will be drawn.
+ /// The rectangle in the specified device context handle to draw the mini-icon in.
+ ///
+ ///
+ /// The index of the mini-icon, as retrieved from SetupDiLoadClassIcon or SetupDiGetClassBitmapIndex. The following predefined
+ /// indexes for devices can be used:
+ ///
+ ///
+ ///
+ /// Class
+ /// Index
+ ///
+ /// -
+ /// Computer/System
+ /// 0
+ ///
+ /// -
+ /// Display/Monitor
+ /// 2
+ ///
+ /// -
+ /// Network Adapter
+ /// 3
+ ///
+ /// -
+ /// Mouse
+ /// 5
+ ///
+ /// -
+ /// Keyboard
+ /// 6
+ ///
+ /// -
+ /// Sound
+ /// 8
+ ///
+ /// -
+ /// FDC/HDC
+ /// 9
+ ///
+ /// -
+ /// Ports
+ /// 10
+ ///
+ /// -
+ /// Printer
+ /// 14
+ ///
+ /// -
+ /// Network Transport
+ /// 15
+ ///
+ /// -
+ /// Network Client
+ /// 16
+ ///
+ /// -
+ /// Network Service
+ /// 17
+ ///
+ /// -
+ /// Unknown
+ /// 18
+ ///
+ ///
+ ///
+ ///
+ /// These flags control the drawing operation. The LOWORD contains the actual flags defined as follows:
+ /// DMI_MASK
+ /// Draw the mini-icon's mask into HDC.
+ /// DMI_BKCOLOR
+ ///
+ /// Use the system color index specified in the HIWORD of Flags as the background color. If this flag is not set, COLOR_WINDOW is used.
+ ///
+ /// DMI_USERECT
+ /// If set, SetupDiDrawMiniIcon uses the supplied rectangle and stretches the icon to fit.
+ ///
+ ///
+ /// This function returns the offset from the left side of rc where the string should start. If the draw operation fails, the
+ /// function returns zero.
+ ///
+ ///
+ /// By default, the icon is centered vertically and forced against the left side of the specified rectangle.
+ ///
+ /// SetupDiDrawMiniIcon draws the 16-bit version of the icon that is specified by the MiniIconIndex parameter. Instead of
+ /// SetupDiDrawMiniIcon, you should use SetupDiLoadClassIcon together with DrawIcon or DrawIconEx to draw the
+ /// 32-bit version of the icon. The following is an example of how to use DrawIconEx to display an icon:
+ ///
+ ///
+ /// HICON hIcon; if (SetupDiLoadClassIcon(&GUID_DEVCLASS_USB, &hIcon, NULL)) { DrawIconEx(hDC, 0, 0, hIcon, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); }
+ ///
+ ///
+ /// For more information about DrawIcon or DrawIconEx, refer to the Microsoft Windows Software Development Kit (SDK) for Windows 7
+ /// and .NET Framework 4.0 documentation.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdidrawminiicon WINSETUPAPI INT SetupDiDrawMiniIcon(
+ // HDC hdc, RECT rc, INT MiniIconIndex, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDrawMiniIcon")]
+ public static extern int SetupDiDrawMiniIcon(HDC hdc, RECT rc, int MiniIconIndex, DMI Flags);
+
///
/// The SetupDiEnumDeviceInfo function returns a SP_DEVINFO_DATA structure that specifies a device information element in a
/// device information set.
@@ -281,6 +1843,583 @@ namespace Vanara.PInvoke
}
}
+ /// The SetupDiEnumDriverInfo function enumerates the members of a driver list.
+ /// A handle to the device information set that contains the driver list to enumerate.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiEnumDriverInfo enumerates a driver list for the
+ /// specified device. If this parameter is NULL, SetupDiEnumDriverInfo enumerates the global class driver list that is
+ /// associated with DeviceInfoSet (this list is of type SPDIT_CLASSDRIVER).
+ ///
+ ///
+ /// The type of driver list to enumerate, which must be one of the following values:
+ /// SPDIT_CLASSDRIVER
+ /// Enumerate a class driver list. This driver list type must be specified if DeviceInfoData is not specified.
+ /// SPDIT_COMPATDRIVER
+ ///
+ /// Enumerate a list of compatible drivers for the specified device. This driver list type can be specified only if DeviceInfoData
+ /// is also specified.
+ ///
+ ///
+ /// The zero-based index of the driver information member to retrieve.
+ ///
+ /// A pointer to a caller-initialized SP_DRVINFO_DATA structure that receives information about the enumerated driver. The caller
+ /// must set DriverInfoData. cbSize to sizeof( SP_DRVINFO_DATA ) before calling SetupDiEnumDriverInfo.
+ /// If the cbSize member is not properly set, SetupDiEnumDriverInfo will return FALSE.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// To enumerate driver information set members, an installer should first call SetupDiEnumDriverInfo with the MemberIndex
+ /// parameter set to 0. It should then increment MemberIndex and call SetupDiEnumDriverInfo until there are no more values.
+ /// When there are no more values, the function fails and a call to GetLastError returns ERROR_NO_MORE_ITEMS.
+ ///
+ ///
+ /// If you do not properly initialize the cbSize member of the SP_DRVINFO_DATA structure that is supplied by the pointer
+ /// DriverInfoData, the function will fail and log the error ERROR_INVALID_USER_BUFFER.
+ ///
+ ///
+ /// To build a list of drivers associated with a specific device or with the global class driver list for a device information set
+ /// first use SetupDiBuildDriverInfoList then pass that list to SetupDiEnumDriverInfo.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdienumdriverinfoa WINSETUPAPI BOOL
+ // SetupDiEnumDriverInfoA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType, DWORD MemberIndex,
+ // PSP_DRVINFO_DATA_A DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiEnumDriverInfoA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiEnumDriverInfo(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, SPDIT DriverType,
+ uint MemberIndex, ref SP_DRVINFO_DATA_V2 DriverInfoData);
+
+ /// The SetupDiEnumDriverInfo function enumerates the members of a driver list.
+ /// A handle to the device information set that contains the driver list to enumerate.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiEnumDriverInfo enumerates a driver list for the
+ /// specified device. If this parameter is NULL, SetupDiEnumDriverInfo enumerates the global class driver list that is
+ /// associated with DeviceInfoSet (this list is of type SPDIT_CLASSDRIVER).
+ ///
+ ///
+ /// The type of driver list to enumerate, which must be one of the following values:
+ /// SPDIT_CLASSDRIVER
+ /// Enumerate a class driver list. This driver list type must be specified if DeviceInfoData is not specified.
+ /// SPDIT_COMPATDRIVER
+ ///
+ /// Enumerate a list of compatible drivers for the specified device. This driver list type can be specified only if DeviceInfoData
+ /// is also specified.
+ ///
+ ///
+ /// The zero-based index of the driver information member to retrieve.
+ ///
+ /// A pointer to a caller-initialized SP_DRVINFO_DATA structure that receives information about the enumerated driver. The caller
+ /// must set DriverInfoData. cbSize to sizeof( SP_DRVINFO_DATA ) before calling SetupDiEnumDriverInfo.
+ /// If the cbSize member is not properly set, SetupDiEnumDriverInfo will return FALSE.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// To enumerate driver information set members, an installer should first call SetupDiEnumDriverInfo with the MemberIndex
+ /// parameter set to 0. It should then increment MemberIndex and call SetupDiEnumDriverInfo until there are no more values.
+ /// When there are no more values, the function fails and a call to GetLastError returns ERROR_NO_MORE_ITEMS.
+ ///
+ ///
+ /// If you do not properly initialize the cbSize member of the SP_DRVINFO_DATA structure that is supplied by the pointer
+ /// DriverInfoData, the function will fail and log the error ERROR_INVALID_USER_BUFFER.
+ ///
+ ///
+ /// To build a list of drivers associated with a specific device or with the global class driver list for a device information set
+ /// first use SetupDiBuildDriverInfoList then pass that list to SetupDiEnumDriverInfo.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdienumdriverinfoa WINSETUPAPI BOOL
+ // SetupDiEnumDriverInfoA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType, DWORD MemberIndex,
+ // PSP_DRVINFO_DATA_A DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiEnumDriverInfoA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiEnumDriverInfo(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, SPDIT DriverType,
+ uint MemberIndex, ref SP_DRVINFO_DATA_V2 DriverInfoData);
+
+ ///
+ /// The SetupDiGetActualModelsSection function retrieves the appropriate decorated INF Models section to use when installing
+ /// a device from a device INF file.
+ ///
+ ///
+ /// A pointer to an INF file context that specifies a manufacturer-identifier entry in an INF Manufacturer section of an INF file.
+ /// The manufacturer-identifier entry specifies an INF Models section name and optionally specifies TargetOSVersion decorations for
+ /// the Models section name. For information about INF files and an INF file context, see the Platform SDK topics on using INF files
+ /// and the INFCONTEXT structure.
+ ///
+ ///
+ /// A pointer to an SP_ALTPLATFORM_INFO structure that supplies information about a Windows version and processor architecture. The
+ /// cbSize member of this structure must be set to sizeof( SP_ALTPLATFORM_INFO_V2 ). This parameter is optional
+ /// and can be set to NULL.
+ ///
+ ///
+ /// A pointer to a buffer that receives a string that contains the decorated INF Models section name and a NULL terminator. If
+ /// AlternatePlatformInfo is not supplied, the decorated INF Models section name applies to the current platform; otherwise the name
+ /// applies to the specified alternative platform. This parameter is optional and can be set to NULL. If this parameter is
+ /// NULL, the function returns TRUE and sets RequiredSize to the size, in characters, that is required to return the
+ /// decorated Models section name and a terminating NULL character.
+ ///
+ ///
+ /// The size, in characters, of the DecoratedModelsSection buffer. If DecoratedModelsSection is NULL, this parameter must be
+ /// set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-type variable that receives the size, in characters, of the DecoratedModelsSection buffer that is required
+ /// to retrieve the decorated Models section name and a terminating NULL character. This parameter is optional and can be set to NULL.
+ ///
+ /// Reserved for internal system use. This parameter must be set to NULL.
+ ///
+ /// SetupDiGetActualModelsSection returns TRUE if the operation succeeds. Otherwise, the function returns FALSE
+ /// and the logged error can be retrieved with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiGetActualModelsSection determines which TargetOSVersion fields in the manufacturer-identifier entry (supplied by
+ /// Context) apply to the current platform, if AlternatePlatformInfo is not supplied, or to an alternative platform, if alternative
+ /// platform information is supplied. SetupDiGetActualModelsSection selects the most appropriate platform based on all the
+ /// TargetOSVersion fields, appends the TargetOSVersion string to the INF Models section name, and returns the decorated INF Models
+ /// section name to the caller. In a manufacturer-identifier entry, the operating system major version is specified by the
+ /// OSMajorVersion field and the operating system minor version is specified by the OSMinorVersion field.
+ ///
+ /// For information about retrieving an INF DDInstall section for a device, see SetupDiGetActualSectionToInstall.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetactualmodelssectiona WINSETUPAPI BOOL
+ // SetupDiGetActualModelsSectionA( PINFCONTEXT Context, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSTR InfSectionWithExt, DWORD
+ // InfSectionWithExtSize, PDWORD RequiredSize, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetActualModelsSectionA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetActualModelsSection(in INFCONTEXT Context, [In, Optional] IntPtr AlternatePlatformInfo,
+ [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder InfSectionWithExt, uint InfSectionWithExtSize,
+ out uint RequiredSize, IntPtr Reserved = default);
+
+ ///
+ /// The SetupDiGetActualSectionToInstall function retrieves the appropriate INF DDInstall section to use when installing a
+ /// device from a device INF file on a local computer.
+ ///
+ /// The handle to the INF file that contains the DDInstall section.
+ ///
+ /// A pointer to the DDInstall section name (as specified in an INF Models section). The maximum length of the section name, in
+ /// characters, is 254.
+ ///
+ ///
+ /// A pointer to a character buffer to receive the DDInstall section name, its platform extension, and a NULL terminator. This is
+ /// the decorated section name that should be used for installation. If this parameter is NULL, InfSectionWithExtSize must be
+ /// zero. If this parameter is NULL, the function returns TRUE and sets RequiredSize to the size, in characters, that
+ /// is required to return the DDInstall section name, its platform extension, and a terminating NULL character.
+ ///
+ ///
+ /// The size, in characters, of the InfSectionWithExt buffer. If InfSectionWithExt is NULL, this parameter must be zero.
+ ///
+ ///
+ /// A pointer to the variable that receives the size, in characters, that is required to return the DDInstall section name, the
+ /// platform extension, and a terminating NULL character.
+ ///
+ ///
+ /// A pointer to a variable that receives a pointer to the '.' character that marks the start of the extension in the
+ /// InfSectionWithExt buffer. If the InfSectionWithExt buffer is not supplied or is too small, this parameter is not set. Set this
+ /// parameter to NULL if a pointer to the extension is not required.
+ ///
+ ///
+ /// If the function is successful, it returns TRUE. If the function fails, it returns FALSE. To get extended error
+ /// information, call GetLastError.
+ ///
+ ///
+ ///
+ /// This function supports the extensions to DDInstall section names that are used to specify OS-specific and architecture-specific
+ /// installation behaviors for a device. For information about these extensions, see Creating INF Files for Multiple Platforms and
+ /// Operating Systems. SetupDiGetActualSectionToInstall searches for a DDInstall section name that matches the local computer
+ /// in the manner described below.
+ ///
+ ///
+ /// The function first searches in the specified INF file for a decorated install section name that matches the specified name and
+ /// has an extension that matches the operating system and processor architecture of the local computer. If, for example, you
+ /// specify a section name of InstallSec, the function searches for one of the following decorated names, depending on the
+ /// processor architecture of the local computer:
+ ///
+ ///
+ /// -
+ /// For a computer that is based on the x86 processor architecture, the function searches for the decorated name InstallSec.ntx86.
+ ///
+ /// -
+ /// For a computer that is based on the x64 processor architecture, the function searches for the decorated name InstallSec.ntamd64.
+ ///
+ /// -
+ /// For a computer that is based on the Itanium processor architecture, the function searches for the decorated name InstallSec.ntia64.
+ ///
+ ///
+ ///
+ /// If the function finds a match for the name, operating system, and processor architecture, it terminates the search and returns
+ /// the corresponding decorated name. If the function does not find such a match, the function searches for a section whose name is
+ /// InstallSec.NT. If the function finds a match for InstallSec.NT, it terminates the search and returns this name. If
+ /// the function does not find a match for either of the above searches, it returns InstallSec, but does not verify that the
+ /// INF file contains an install section whose name is InstallSec.
+ ///
+ ///
+ /// The DDInstall section name is used as the base for Hardware and Services section names. For example, if the
+ /// DDInstall section name that is found is InstallSec.NTX86, the Services section name must be named InstallSec.NTX86.Services.
+ ///
+ ///
+ /// The original DDInstall section name that is specified in the driver node is written to the driver's registry key's
+ /// InfSection value entry. The extension that was found is stored in the key as the REG_SZ value InfSectionExt. For example:
+ ///
+ ///
+ /// InfSection : REG_SZ : "InstallSec" InfSectionExt : REG_SZ : ".NTX86"
+ ///
+ ///
+ /// If a driver is not selected for the specified device information element, a null driver is installed. Upon return, the flags in
+ /// the device's SP_DEVINSTALL_PARAMS structure indicate whether the system should be restarted or rebooted to cause the device to start.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetactualsectiontoinstalla WINSETUPAPI BOOL
+ // SetupDiGetActualSectionToInstallA( HINF InfHandle, PCSTR InfSectionName, PSTR InfSectionWithExt, DWORD InfSectionWithExtSize,
+ // PDWORD RequiredSize, PSTR *Extension );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetActualSectionToInstallA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetActualSectionToInstall(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string InfSectionName,
+ [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder InfSectionWithExt, uint InfSectionWithExtSize,
+ out uint RequiredSize, out StrPtrAuto Extension);
+
+ ///
+ /// The SetupDiGetActualSectionToInstallEx function retrieves the name of the INF DDInstall section that installs a device
+ /// for a specified operating system and processor architecture.
+ ///
+ /// A handle to the INF file that contains the DDInstall section.
+ ///
+ /// A pointer to the DDInstall section name (as specified in an INF Models section). The maximum length of the section name, in
+ /// characters, is 254.
+ ///
+ ///
+ ///
+ /// A pointer, if non- NULL, to an SP_ALTPLATFORM_INFO structure. This structure is used to specify an operating system and
+ /// processor architecture that is different from that on the local computer. To return the DDInstall section name for the local
+ /// computer, set this parameter to NULL. Otherwise, provide an SP_ALTPLATFORM structure and set its members as follows:
+ ///
+ /// cbSize
+ /// Set to the size, in bytes, of an SP_ALTPLATFORM_INFO structure.
+ /// Platform
+ /// Set to VER_PLATFORM_WIN32_NT for Windows XP and later versions of Windows.
+ /// MajorVersion
+ /// Not used.
+ /// MinorVersion
+ /// Not Used.
+ /// ProcessorArchitecture
+ /// Set one of the following processor architecture constants.
+ ///
+ ///
+ /// Processor Architecture Constant
+ /// Meaning
+ ///
+ /// -
+ /// PROCESSOR_ARCHITECTURE_INTEL
+ /// The alternative platform is an x86-based processor architecture.
+ ///
+ /// -
+ /// PROCESSOR_ARCHITECTURE_IA64
+ /// The alternative platform is an Itanium-based processor architecture.
+ ///
+ /// -
+ /// PROCESSOR_ARCHITECTURE_AMD64
+ /// The alternative platform is an x64-based processor architecture.
+ ///
+ ///
+ /// Reserved
+ /// Set to zero.
+ ///
+ ///
+ /// A pointer to a character buffer to receive the DDInstall section name, its platform extension, and a NULL terminator. This is
+ /// the decorated section name that should be used for installation. If this parameter is NULL, the function returns
+ /// TRUE and sets RequiredSize to the size, in characters, that is required to return the DDInstall section name, its
+ /// platform extension, and a terminating NULL character.
+ ///
+ ///
+ /// The size, in characters, of the buffer that is pointed to by the InfSectionWithExt parameter. The maximum length of a
+ /// NULL-terminated INF section name, in characters, is MAX_INF_SECTION_NAME_LENGTH.
+ ///
+ ///
+ /// A pointer to the variable that receives the size, in characters, that is required to return the DDInstall section name, the
+ /// platform extension, and a terminating NULL character.
+ ///
+ ///
+ /// A pointer to a variable that receives a pointer to the '.' character that marks the start of the extension in the
+ /// InfSectionWithExt buffer. If the InfSectionWithExt buffer is not supplied or is too small, this parameter is not set. Set this
+ /// parameter to NULL if a pointer to the extension is not required.
+ ///
+ /// Reserved for internal use only. Must be set to NULL.
+ ///
+ /// If the function is successful, it returns TRUE. Otherwise, it returns FALSE. To get extended error information,
+ /// call GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiGetActualSectionToInstallEx is an extended form of SetupDiGetActualSectionToInstall. These functions support the
+ /// extensions to DDInstall section names that are used to specify OS-specific and architecture-specific installation actions for a
+ /// device. For information about these extensions, see Creating INF Files for Multiple Platforms and Operating Systems.
+ ///
+ ///
+ /// If you do not supply alternative platform information with a call to SetupDiGetActualSectionToInstallEx, the function
+ /// performs the same operation as SetupDiGetActualSectionToInstall. The latter function searches for the specified install
+ /// section name using the platform information for the local computer.
+ ///
+ ///
+ /// If you supply alternative platform information with a call to SetupDiGetActualSectionToInstallEx, the function does the following:
+ ///
+ ///
+ /// -
+ ///
+ /// If you specify a platform of VER_PLATFORM_WIN32_NT, the function first searches in the specified INF file for a decorated
+ /// install section name that matches the name, operating system, and processor architecture that you specify. If, for example, you
+ /// specify an install section name of InstallSec, the function searches for one of the following decorated names, depending
+ /// on the specified processor architecture:
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetactualsectiontoinstallexa WINSETUPAPI BOOL
+ // SetupDiGetActualSectionToInstallExA( HINF InfHandle, PCSTR InfSectionName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSTR
+ // InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PSTR *Extension, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetActualSectionToInstallExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetActualSectionToInstallEx(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string InfSectionName,
+ [In, Optional] IntPtr AlternatePlatformInfo, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder InfSectionWithExt,
+ uint InfSectionWithExtSize, out uint RequiredSize, out StrPtrAuto Extension, IntPtr Reserved = default);
+
+ /// The SetupDiGetClassBitmapIndex function retrieves the index of the mini-icon supplied for the specified class.
+ ///
+ /// A pointer to the GUID of the device setup class for which to retrieve the mini-icon. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a variable of type INT that receives the index of the mini-icon for the specified device setup class. If the
+ /// ClassGuid parameter is NULL or if there is no mini-icon for the specified class, SetupDiGetClassBitmapIndex
+ /// returns the index of the mini-icon for the Unknown device setup class.
+ ///
+ ///
+ /// If there is a min-icon for the specified device setup class, SetupDiGetClassBitmapIndex returns TRUE. Otherwise,
+ /// this function returns FALSE and the logged error can be retrieved with a call to GetLastError. If the ClassGuid parameter
+ /// is NULL, or if there is no mini-icon for the specified class, the function returns FALSE and GetLastError returns ERROR_NO_DEVICE_ICON.
+ ///
+ /// For a list of the device setup class mini-icons and their corresponding indexes, see SetupDiDrawMiniIcon.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassbitmapindex WINSETUPAPI BOOL
+ // SetupDiGetClassBitmapIndex( const GUID *ClassGuid, PINT MiniIconIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassBitmapIndex")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassBitmapIndex(in Guid ClassGuid, out int MiniIconIndex);
+
+ /// The SetupDiGetClassBitmapIndex function retrieves the index of the mini-icon supplied for the specified class.
+ ///
+ /// A pointer to the GUID of the device setup class for which to retrieve the mini-icon. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a variable of type INT that receives the index of the mini-icon for the specified device setup class. If the
+ /// ClassGuid parameter is NULL or if there is no mini-icon for the specified class, SetupDiGetClassBitmapIndex
+ /// returns the index of the mini-icon for the Unknown device setup class.
+ ///
+ ///
+ /// If there is a min-icon for the specified device setup class, SetupDiGetClassBitmapIndex returns TRUE. Otherwise,
+ /// this function returns FALSE and the logged error can be retrieved with a call to GetLastError. If the ClassGuid parameter
+ /// is NULL, or if there is no mini-icon for the specified class, the function returns FALSE and GetLastError returns ERROR_NO_DEVICE_ICON.
+ ///
+ /// For a list of the device setup class mini-icons and their corresponding indexes, see SetupDiDrawMiniIcon.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassbitmapindex WINSETUPAPI BOOL
+ // SetupDiGetClassBitmapIndex( const GUID *ClassGuid, PINT MiniIconIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassBitmapIndex")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassBitmapIndex([In, Optional] IntPtr ClassGuid, out int MiniIconIndex);
+
+ ///
+ /// The SetupDiGetClassDescription function retrieves the class description associated with the specified setup class GUID.
+ ///
+ /// The GUID of the setup class whose description is to be retrieved.
+ /// A pointer to a character buffer that receives the class description.
+ /// The size, in characters, of the ClassDescription buffer.
+ ///
+ /// A pointer to variable of type DWORD that receives the size, in characters, that is required to store the class description
+ /// (including a NULL terminator). RequiredSize is always less than LINE_LEN. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ /// Call SetupDiGetClassDescriptionEx to retrieve the description of a setup class installed on a remote computer.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdescriptiona WINSETUPAPI BOOL
+ // SetupDiGetClassDescriptionA( const GUID *ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDescriptionA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassDescription(in Guid ClassGuid, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ClassDescription,
+ uint ClassDescriptionSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetClassDescriptionEx function retrieves the description of a setup class installed on a local or remote computer.
+ ///
+ /// A pointer to the GUID for the setup class whose description is to be retrieved.
+ /// A pointer to a character buffer that receives the class description.
+ ///
+ /// The size, in characters, of the buffer that is pointed to by the ClassDescription parameter. The maximum length, in characters,
+ /// of a NULL-terminated class description is LINE_LEN. For more information, see the following Remarks section.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the size, in characters, that is required to store the requested
+ /// NULL-terminated class description. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that supplies the name of a remote computer on which the setup class resides. This pointer
+ /// is optional and can be NULL. If the class is installed on a local computer, set the pointer to NULL.
+ ///
+ /// Reserved for system use. A caller of this function must set this parameter to NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If there is a friendly name in the registry key for the class, this routine returns the friendly name. Otherwise, this routine
+ /// returns the class name.
+ ///
+ ///
+ /// SetupDiGetClassDescriptionEx does not enforce a restriction on the length of the class description that it can return.
+ /// This function returns the required size for a NULL-terminated class description even if it is greater than LINE_LEN. However,
+ /// LINE_LEN is the maximum length of a valid NULL-terminated class description. A caller should never need a buffer that is larger
+ /// than LINE_LEN.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdescriptionexa WINSETUPAPI BOOL
+ // SetupDiGetClassDescriptionExA( const GUID *ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize,
+ // PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDescriptionExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassDescriptionEx(in Guid ClassGuid, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ClassDescription,
+ uint ClassDescriptionSize, out uint RequiredSize, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, IntPtr Reserved = default);
+
+ ///
+ /// The SetupDiGetClassDevPropertySheets function retrieves handles to the property sheets of a device information element or
+ /// of the device setup class of a device information set.
+ ///
+ ///
+ /// A handle to the device information set for which to return property sheet handles. If DeviceInfoData does not specify a device
+ /// information element in the device information set, the device information set must have an associated device setup class.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet.
+ ///
+ /// This parameter is optional and can be NULL. If this parameter is specified, SetupDiGetClassDevPropertySheets
+ /// retrieves the property sheets handles that are associated with the specified device. If this parameter is NULL,
+ /// SetupDiGetClassDevPropertySheets retrieves the property sheets handles that are associated with the device setup class
+ /// specified in DeviceInfoSet.
+ ///
+ ///
+ ///
+ ///
+ /// A pointer to a PROPERTYSHEETHEADER structure. See the Remarks section for information about the caller-supplied array of
+ /// property sheet handles that is associated with this structure.
+ ///
+ /// For more documentation on this structure and property sheets in general, see the Microsoft Windows SDK.
+ ///
+ ///
+ /// The maximum number of handles that the caller-supplied array of property sheet handles can hold.
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the number of property sheets that are associated with the specified device
+ /// information element or the device setup class of the specified device information set. The pointer is optional and can be NULL.
+ ///
+ ///
+ /// A flag that indicates one of the following types of property sheets.
+ ///
+ ///
+ /// Property sheet type
+ /// Meaning
+ ///
+ /// -
+ /// DIGCDP_FLAG_ADVANCED
+ /// Advanced property sheets.
+ ///
+ /// -
+ /// DIGCDP_FLAG_BASIC
+ ///
+ /// Basic property sheets. Supported only in Microsoft Windows 95 and Windows 98. Do not use in Windows 2000 and later versions of Windows.
+ ///
+ ///
+ /// -
+ /// DIGCDP_FLAG_REMOTE_ADVANCED
+ /// Advanced property sheets on a remote computer.
+ ///
+ ///
+ ///
+ ///
+ /// The function returns TRUE if successful. Otherwise, the function returns FALSE. Call GetLastError to obtain the
+ /// error code.
+ ///
+ ///
+ ///
+ /// A PROPERTYSHEETHEADER structure contains two members that are associated with a caller-supplied array that the function uses to
+ /// return the handles of property sheets. The phpages member is a pointer to a caller-supplied array of property sheet
+ /// handles, and the input value of the nPages member specifies the number of handles that are already contained in the
+ /// handle array. The function adds property sheet handles to the handle array beginning with the array element whose array index is
+ /// the input value of nPages. The function adds handles to the array in consecutive order until either the array is full or
+ /// the handles of all the requested property sheet pages have been added to the array. The maximum number of property sheet handles
+ /// that the function can return is equal to (PropertySheetHeaderPageListSize - (input value of nPages)).
+ ///
+ /// If the handle array is large enough to hold the handles of all the requested property sheet pages, the function:
+ ///
+ /// -
+ /// Adds the handles to the handle array.
+ ///
+ /// -
+ /// Sets nPages to the total number of handles in the array.
+ ///
+ /// -
+ /// Sets RequiredSize to the number of handles that it returns.
+ ///
+ /// -
+ /// Returns TRUE.
+ ///
+ ///
+ /// If the handle array is not large enough to hold the handles of all the specified property sheet pages, the function:
+ ///
+ /// -
+ /// Adds as many handles as the array can hold.
+ ///
+ /// -
+ /// Sets nPages to PropertySheetHeaderPageListSize.
+ ///
+ /// -
+ ///
+ /// Sets RequiredSize to the total number of requested property sheet pages. The number of handles that are not returned by the
+ /// function is equal to (RequiredSize - PropertySheetHeaderPageListSize - (input value of nPages)).
+ ///
+ ///
+ /// -
+ /// Sets the error code to ERROR_INSUFFICIENT_BUFFER.
+ ///
+ /// -
+ /// Returns FALSE.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdevpropertysheetsa WINSETUPAPI BOOL
+ // SetupDiGetClassDevPropertySheetsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, LPPROPSHEETHEADERA
+ // PropertySheetHeader, DWORD PropertySheetHeaderPageListSize, PDWORD RequiredSize, DWORD PropertySheetType );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevPropertySheetsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassDevPropertySheets(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [In] IntPtr PropertySheetHeader, uint PropertySheetHeaderPageListSize, out uint RequiredSize, DIGCDP_FLAG PropertySheetType);
+
///
/// The SetupDiGetClassDevs function returns a handle to a device information set that contains requested device information
/// elements for a local computer.
@@ -688,644 +2827,562 @@ namespace Vanara.PInvoke
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevsW")]
public static extern SafeHDEVINFO SetupDiGetClassDevs([In, Optional] IntPtr ClassGuid, [In, Optional] string Enumerator, [In, Optional] HWND hwndParent, DIGCF Flags);
- /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
- ///
- /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
- /// returned by SetupDiGetClassDevs.
+ ///
+ /// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device
+ /// information elements for a local or a remote computer.
+ ///
+ ///
+ /// A pointer to the GUID for a device setup class or a device interface class. This pointer is optional and can be NULL. If
+ /// a GUID value is not used to select devices, set ClassGuid to NULL. For more information about how to use ClassGuid, see
+ /// the following Remarks section.
///
- ///
- /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details.
- /// A pointer of this type is typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ /// A pointer to a NULL-terminated string that specifies:
+ ///
+ /// -
+ ///
+ /// An identifier (ID) of a Plug and Play (PnP) enumerator. This ID can either be the enumerator's globally unique identifier (GUID)
+ /// or symbolic name. For example, "PCI" can be used to specify the PCI PnP enumerator. Other examples of symbolic names for PnP
+ /// enumerators include "USB", "PCMCIA", and "SCSI".
+ ///
+ ///
+ /// -
+ /// A PnP device instance IDs. When specifying a PnP device instance ID, DIGCF_DEVICEINTERFACE must be set in the Flags parameter.
+ ///
+ ///
+ /// This pointer is optional and can be
+ /// NULL
+ /// . If an
+ /// Enumerator
+ /// value is not used to select devices, set
+ /// Enumerator
+ /// to
+ /// NULL
+ /// For more information about how to set the Enumerator value, see the following Remarks section.
///
- ///
- /// A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure to receive information about the specified interface. This parameter
- /// is optional and can be NULL. This parameter must be NULL if DeviceInterfaceDetailSize is zero. If this parameter
- /// is specified, the caller must set DeviceInterfaceDetailData .cbSize to sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
- /// before calling this function. The cbSize member always contains the size of the fixed part of the data structure, not a
- /// size reflecting the variable-length string at the end.
+ ///
+ /// A handle to the top-level window to be used for a user interface that is associated with installing a device instance in the
+ /// device information set. This handle is optional and can be NULL.
///
- ///
+ ///
///
- /// The size of the DeviceInterfaceDetailData buffer. The buffer must be at least ( offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA,
- /// DevicePath) + sizeof(TCHAR)) bytes, to contain the fixed part of the structure and a single NULL to
- /// terminate an empty MULTI_SZ string.
+ /// A variable of type DWORD that specifies control options that filter the device information elements that are added to the device
+ /// information set. This parameter can be a bitwise OR of one or more of the following flags. For more information about combining
+ /// these control options, see the following Remarks section.
///
- /// This parameter must be zero if DeviceInterfaceDetailData is NULL.
+ /// DIGCF_ALLCLASSES
+ /// Return a list of installed devices for the specified device setup classes or device interface classes.
+ /// DIGCF_DEVICEINTERFACE
+ ///
+ /// Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags
+ /// parameter if the Enumerator parameter specifies a device instance ID.
+ ///
+ /// DIGCF_DEFAULT
+ ///
+ /// Return only the device that is associated with the system default device interface, if one is set, for the specified device
+ /// interface classes.
+ ///
+ /// DIGCF_PRESENT
+ /// Return only devices that are currently present.
+ /// DIGCF_PROFILE
+ /// Return only devices that are a part of the current hardware profile.
///
- ///
- /// A pointer to a variable of type DWORD that receives the required size of the DeviceInterfaceDetailData buffer. This size
- /// includes the size of the fixed part of the structure plus the number of bytes required for the variable-length device path
- /// string. This parameter is optional and can be NULL.
+ ///
+ /// The handle to an existing device information set to which SetupDiGetClassDevsEx adds the requested device information
+ /// elements. This parameter is optional and can be set to NULL. For more information about using this parameter, see the
+ /// following Remarks section.
///
- ///
- /// A pointer to a buffer that receives information about the device that supports the requested interface. The caller must set
- /// DeviceInfoData .cbSize to sizeof(SP_DEVINFO_DATA). This parameter is optional and can be NULL.
+ ///
+ /// A pointer to a constant string that contains the name of a remote computer on which the devices reside. A value of NULL
+ /// for MachineName specifies that the device is installed on the local computer.
///
+ /// Reserved for internal use. This parameter must be set to NULL.
///
- /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
- /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ /// If the operation succeeds, SetupDiGetClassDevsEx returns a handle to a device information set that contains all installed
+ /// devices that matched the supplied parameters. If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended
+ /// error information, call GetLastError.
///
///
- /// Using this function to get details about an interface is typically a two-step process:
+ ///
+ /// The caller of SetupDiGetClassDevsEx must delete the returned device information set when it is no longer needed by
+ /// calling SetupDiDestroyDeviceInfoList.
+ ///
+ ///
+ /// If DeviceInfoSet is NULL, SetupDiGetClassDevsEx creates a new device information set that contains the retrieved
+ /// device information elements and returns a handle to the new device information set. If the caller requests that the function
+ /// retrieve devices for a device setup class that is supplied by the ClassGuid parameter, the function sets the device setup class
+ /// of the new device information set to the supplied class GUID.
+ ///
+ ///
+ /// If DeviceInfoSet is not set to NULL, the function adds the retrieved device information elements to the device
+ /// information set that is associated with the supplied handle, and returns the supplied handle. If ClassGuid supplies a device
+ /// setup class, the device setup class of the supplied device information set must be set to the supplied class GUID.
+ ///
+ /// Device Setup Class Control Options
+ ///
+ /// Use the following filtering options to control whether SetupDiGetClassDevsEx returns devices for all device setup classes
+ /// or only for a specified device setup class:
+ ///
+ ///
+ /// -
+ /// To return devices for all device setup classes, set the DIGCF_ALLCLASSES flag and set the ClassGuid parameter to NULL.
+ ///
+ /// -
+ ///
+ /// To return devices only for a specific device setup class, do not set DIGCF_ALLCLASSES and use ClassGuid to supply the GUID of
+ /// the device setup class.
+ ///
+ ///
+ ///
+ /// In addition, you can use the following filtering options to further restrict which devices are returned.
+ ///
+ /// -
+ /// To return only devices that are present in the system, set the DIGCF_PRESENT flag.
+ ///
+ /// -
+ /// To return only devices that are part of the current hardware profile, set the DIGCF_PROFILE flag.
+ ///
+ /// -
+ ///
+ /// To return devices for a specific PnP enumerator only, use the Enumerator parameter to supply the GUID or symbolic name of the
+ /// enumerator. If Enumerator is NULL, SetupDiGetClassDevsEx returns devices for all PnP enumerators.
+ ///
+ ///
+ ///
+ /// Device Interface Class Control Options
+ ///
+ /// Use the following filtering options to control whether SetupDiGetClassDevsEx returns devices that support any device
+ /// interface class or only devices that support a specified device interface class:
+ ///
+ ///
+ /// -
+ ///
+ /// To return devices that support a device interface of any class, set the DIGCF_DEVICEINTERFACE flag, set the DIGCF_ALLCLASSES
+ /// flag, and set ClassGuid to NULL. The function adds to the device information set a device information element that
+ /// represents such a device, and then adds to the device information element a device interface list that contains all the device
+ /// interfaces that the device supports.
+ ///
+ ///
+ /// -
+ ///
+ /// To return only devices that support a device interface of a specified class, set the DIGCF_DEVICEINTERFACE flag and use the
+ /// ClassGuid parameter to supply the class GUID of the device interface class. The function adds to the device information set a
+ /// device information element that represents such a device, and then adds a device interface of the specified class to the device
+ /// interface list for that device information element.
+ ///
+ ///
+ ///
+ ///
+ /// In addition, you can use the following filtering options to control whether SetupDiGetClassDevsEx returns only devices
+ /// that support the system default interface for device interface classes:
+ ///
+ ///
+ /// -
+ ///
+ /// To return only the device that supports the system default interface, if one is set, for a specified device interface class, set
+ /// the DIGCF_DEVICEINTERFACE flag, set the DIGCF_DEFAULT flag, and use ClassGuid to supply the class GUID of the device interface
+ /// class. The function adds to the device information set a device information element that represents such a device, and then adds
+ /// the system default interface to the device interface list for that device information element.
+ ///
+ ///
+ /// -
+ ///
+ /// To return a device that supports a system default interface for an unspecified device interface class, set the
+ /// DIGCF_DEVICEINTERFACE flag, set the DIGCF_ALLCLASSES flag, set the DIGCF_DEFAULT flag, and set ClassGuid to NULL. The
+ /// function adds to the device information set a device information element that represents such a device, and then adds the system
+ /// default interface to the device interface list for that device information element.
+ ///
+ ///
+ ///
+ /// You can also use the following options in combination with the other options to further restrict which devices are returned.
+ ///
+ /// -
+ /// To return only devices that are present in the system, set the DIGCF_PRESENT flag.
+ ///
+ /// -
+ /// To return only devices that are part of the current hardware profile, set the DIGCF_PROFILE flag.
+ ///
+ /// -
+ ///
+ /// To return only a specific device, set the DIGCF_DEVICEINTERFACE flag and use the Enumerator parameter to supply the device
+ /// instance ID of the device. To include all possible devices, set Enumerator to NULL.
+ ///
+ ///
+ ///
+ /// Retrieving Devices in a Device Setup Class That Support a Device Interface Class
+ ///
+ /// An installer can use SetupDiGetClassDevsEx to retrieve a list of devices of a particular device setup class that support
+ /// a device interface of a specified device interface class. For example, to retrieve a list of all devices on a local computer
+ /// that support a device interface in the "mounted device" interface class and that are members of the "Volume" device setup class,
+ /// an installer should perform the following operations:
+ ///
///
/// -
///
- /// Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULL DeviceInterfaceDetailData pointer,
- /// a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize variable. In response to such a call, this function returns
- /// the required buffer size at RequiredSize and fails with GetLastError returning ERROR_INSUFFICIENT_BUFFER.
+ /// Call SetupDiCreateDeviceInfoList to create an empty device information set for the "Volume" device setup class. Set ClassGuid to
+ /// a pointer to the class GUID for the "Volume" device setup class and set hwndParent as appropriate. In response to such a call,
+ /// the function will return a handle to type HDEVINFO to the device information set.
///
///
/// -
- /// Allocate an appropriately sized buffer and call the function again to get the interface details.
+ /// Call SetupDiGetClassDevsEx with the following settings:
///
///
///
- /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as
- /// CreateFile. Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
- ///
- ///
- /// SetupDiGetDeviceInterfaceDetail can be used to get just the DeviceInfoData. If the interface exists but
- /// DeviceInterfaceDetailData is NULL, this function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the
- /// DeviceInfoData structure is filled with information about the device that exposes the interface.
+ /// In an operation of this type, SetupDiGetClassDevsEx returns a device if the device setup class of the device is the same
+ /// as the supplied device information set and if the device supports a device interface whose class is the same as the specified
+ /// device interface class.
///
///
- // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
- // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
- // PSP_DEVINFO_DATA DeviceInfoData );
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdevsexa WINSETUPAPI HDEVINFO
+ // SetupDiGetClassDevsExA( const GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags, HDEVINFO DeviceInfoSet, PCSTR
+ // MachineName, PVOID Reserved );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- [Out, Optional] IntPtr DeviceInterfaceDetailData, uint DeviceInterfaceDetailDataSize, out uint RequiredSize, ref SP_DEVINFO_DATA DeviceInfoData);
-
- /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
- ///
- /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
- /// returned by SetupDiGetClassDevs.
- ///
- ///
- /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details.
- /// A pointer of this type is typically returned by SetupDiEnumDeviceInterfaces.
- ///
- ///
- /// A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure to receive information about the specified interface. This parameter
- /// is optional and can be NULL. This parameter must be NULL if DeviceInterfaceDetailSize is zero. If this parameter
- /// is specified, the caller must set DeviceInterfaceDetailData .cbSize to sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
- /// before calling this function. The cbSize member always contains the size of the fixed part of the data structure, not a
- /// size reflecting the variable-length string at the end.
- ///
- ///
- ///
- /// The size of the DeviceInterfaceDetailData buffer. The buffer must be at least ( offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA,
- /// DevicePath) + sizeof(TCHAR)) bytes, to contain the fixed part of the structure and a single NULL to
- /// terminate an empty MULTI_SZ string.
- ///
- /// This parameter must be zero if DeviceInterfaceDetailData is NULL.
- ///
- ///
- /// A pointer to a variable of type DWORD that receives the required size of the DeviceInterfaceDetailData buffer. This size
- /// includes the size of the fixed part of the structure plus the number of bytes required for the variable-length device path
- /// string. This parameter is optional and can be NULL.
- ///
- ///
- /// A pointer to a buffer that receives information about the device that supports the requested interface. The caller must set
- /// DeviceInfoData .cbSize to sizeof(SP_DEVINFO_DATA). This parameter is optional and can be NULL.
- ///
- ///
- /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
- /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
- ///
- ///
- /// Using this function to get details about an interface is typically a two-step process:
- ///
- /// -
- ///
- /// Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULL DeviceInterfaceDetailData pointer,
- /// a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize variable. In response to such a call, this function returns
- /// the required buffer size at RequiredSize and fails with GetLastError returning ERROR_INSUFFICIENT_BUFFER.
- ///
- ///
- /// -
- /// Allocate an appropriately sized buffer and call the function again to get the interface details.
- ///
- ///
- ///
- /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as
- /// CreateFile. Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
- ///
- ///
- /// SetupDiGetDeviceInterfaceDetail can be used to get just the DeviceInfoData. If the interface exists but
- /// DeviceInterfaceDetailData is NULL, this function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the
- /// DeviceInfoData structure is filled with information about the device that exposes the interface.
- ///
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
- // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
- // PSP_DEVINFO_DATA DeviceInfoData );
- [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- [Out, Optional] IntPtr DeviceInterfaceDetailData, uint DeviceInterfaceDetailDataSize, out uint RequiredSize, IntPtr DeviceInfoData = default);
-
- /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
- ///
- /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
- /// returned by SetupDiGetClassDevs.
- ///
- ///
- /// An SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details. This value is
- /// typically returned by SetupDiEnumDeviceInterfaces.
- ///
- ///
- /// A string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile.
- ///
- /// Receives information about the device that supports the requested interface.
- ///
- /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
- /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
- // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
- // PSP_DEVINFO_DATA DeviceInfoData );
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
- public static bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, out string DeviceInterfacePath, out SP_DEVINFO_DATA DeviceInfoData)
- {
- SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, default, 0, out var sz);
- Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER);
- using var mem = new SafeSP_DEVICE_INTERFACE_DETAIL_DATA(sz);
- DeviceInfoData = new SP_DEVINFO_DATA { cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA)) };
- var ret = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, mem, sz, out sz, ref DeviceInfoData);
- DeviceInterfacePath = ret ? mem.DevicePath : null;
- return ret;
- }
-
- /// The SetupDiGetDeviceProperty function 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 SP_DEVINFO_DATA structure that represents the device instance for which to retrieve a device instance property.
- ///
- ///
- /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
- ///
- ///
- /// A pointer to a DEVPROPTYPE-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. SetupDiGetDeviceProperty 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, SetupDiGetDeviceProperty returns the size of the
- /// property, in bytes, in *RequiredSize.
- ///
- ///
- /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize 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.
- ///
- ///
- /// SetupDiGetDeviceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
- /// error can be retrieved by calling GetLastError.
- ///
- /// The following table includes some of the more common error codes that this function might log.
- ///
- ///
- /// Return code
- /// Description
- ///
- /// -
- /// ERROR_INVALID_FLAGS
- /// The value of Flags is not zero.
- ///
- /// -
- /// ERROR_INVALID_HANDLE
- /// The device information set that is specified by DevInfoSet is not valid.
- ///
- /// -
- /// ERROR_INVALID_PARAMETER
- /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
- ///
- /// -
- /// ERROR_INVALID_REG_PROPERTY
- /// The property key that is supplied by PropertyKey is not valid.
- ///
- /// -
- /// ERROR_INVALID_DATA
- /// An unspecified internal data value was not valid.
- ///
- /// -
- /// ERROR_INVALID_USER_BUFFER
- /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL and PropertBufferSize is not zero.
- ///
- /// -
- /// ERROR_NO_SUCH_DEVINST
- /// The device instance that is specified by DevInfoData does not exist.
- ///
- /// -
- /// ERROR_INSUFFICIENT_BUFFER
- ///
- /// The PropertyBuffer buffer is too small to hold the requested property value, or an internal data buffer that was passed to a
- /// system call was too small.
- ///
- ///
- /// -
- /// ERROR_NOT_ENOUGH_MEMORY
- /// There was not enough system memory available to complete the operation.
- ///
- /// -
- /// ERROR_NOT_FOUND
- /// The requested device property does not exist.
- ///
- /// -
- /// ERROR_ACCESS_DENIED
- /// The caller does not have Administrator privileges.
- ///
- ///
- ///
- ///
- /// SetupDiGetDeviceProperty is part of the unified device property model.
- /// SetupAPI supports only a Unicode version of SetupDiGetDeviceProperty.
- /// To obtain the device property keys that represent the device properties that are set for a device instance, call SetupDiGetDevicePropertyKeys.
- /// To set a device instance property, call SetupDiSetDeviceProperty.
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdevicepropertyw WINSETUPAPI BOOL
- // SetupDiGetDevicePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const DEVPROPKEY *PropertyKey, DEVPROPTYPE
- // *PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags );
- [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyW")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool SetupDiGetDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in DEVPROPKEY PropertyKey,
- out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize, uint Flags = 0);
-
- /// The SetupDiGetDeviceProperty function 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 SP_DEVINFO_DATA structure that represents the device instance for which to retrieve a device instance property.
- ///
- ///
- /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
- ///
- ///
- /// A pointer to a buffer that receives the requested device instance property. SetupDiGetDeviceProperty 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, SetupDiGetDeviceProperty returns the size of the
- /// property, in bytes, in *RequiredSize.
- ///
- ///
- ///
- /// SetupDiGetDeviceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
- /// error can be retrieved by calling GetLastError.
- ///
- /// The following table includes some of the more common error codes that this function might log.
- ///
- ///
- /// Return code
- /// Description
- ///
- /// -
- /// ERROR_INVALID_FLAGS
- /// The value of Flags is not zero.
- ///
- /// -
- /// ERROR_INVALID_HANDLE
- /// The device information set that is specified by DevInfoSet is not valid.
- ///
- /// -
- /// ERROR_INVALID_PARAMETER
- /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
- ///
- /// -
- /// ERROR_INVALID_REG_PROPERTY
- /// The property key that is supplied by PropertyKey is not valid.
- ///
- /// -
- /// ERROR_INVALID_DATA
- /// An unspecified internal data value was not valid.
- ///
- /// -
- /// ERROR_INVALID_USER_BUFFER
- /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL and PropertBufferSize is not zero.
- ///
- /// -
- /// ERROR_NO_SUCH_DEVINST
- /// The device instance that is specified by DevInfoData does not exist.
- ///
- /// -
- /// ERROR_INSUFFICIENT_BUFFER
- ///
- /// The PropertyBuffer buffer is too small to hold the requested property value, or an internal data buffer that was passed to a
- /// system call was too small.
- ///
- ///
- /// -
- /// ERROR_NOT_ENOUGH_MEMORY
- /// There was not enough system memory available to complete the operation.
- ///
- /// -
- /// ERROR_NOT_FOUND
- /// The requested device property does not exist.
- ///
- /// -
- /// ERROR_ACCESS_DENIED
- /// The caller does not have Administrator privileges.
- ///
- ///
- ///
- ///
- /// SetupDiGetDeviceProperty is part of the unified device property model.
- /// SetupAPI supports only a Unicode version of SetupDiGetDeviceProperty.
- /// To obtain the device property keys that represent the device properties that are set for a device instance, call SetupDiGetDevicePropertyKeys.
- /// To set a device instance property, call SetupDiSetDeviceProperty.
- ///
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyW")]
- public static bool SetupDiGetDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in DEVPROPKEY PropertyKey, out object Value)
- {
- Value = null;
- if (!SetupDiGetDeviceProperty(DeviceInfoSet, DeviceInfoData, PropertyKey, out _, default, 0, out var sz) && Win32Error.GetLastError() != Win32Error.ERROR_INSUFFICIENT_BUFFER)
- return false;
- using var mem = new SafeCoTaskMemHandle(sz);
- if (SetupDiGetDeviceProperty(DeviceInfoSet, DeviceInfoData, PropertyKey, out var propType, mem, mem.Size, out _))
- {
- switch (propType)
- {
- case DEVPROPTYPE.DEVPROP_TYPE_EMPTY:
- case DEVPROPTYPE.DEVPROP_TYPE_NULL:
- Value = null;
- return true;
-
- case DEVPROPTYPE.DEVPROP_TYPE_SECURITY_DESCRIPTOR:
- Value = new System.Security.AccessControl.RawSecurityDescriptor(mem.GetBytes(0, mem.Size), 0);
- return true;
-
- case DEVPROPTYPE.DEVPROP_TYPE_STRING_INDIRECT:
- Value = mem.ToString(-1, CharSet.Unicode);
- return true;
-
- case DEVPROPTYPE.DEVPROP_TYPE_STRING_LIST:
- Value = mem.ToStringEnum(CharSet.Unicode).ToArray();
- return true;
-
- default:
- (DEVPROPTYPE type, DEVPROPTYPE mod) spt = propType.Split();
- var type = CorrespondingTypeAttribute.GetCorrespondingTypes(spt.type).FirstOrDefault();
- if (type is not null)
- {
- Value = spt.mod switch
- {
- 0 => mem.DangerousGetHandle().Convert(mem.Size, type, CharSet.Unicode),
- DEVPROPTYPE.DEVPROP_TYPEMOD_ARRAY => mem.DangerousGetHandle().ToArray(type, mem.Size / Marshal.SizeOf(type), 0, mem.Size),
- _ => null
- };
- if (Value is not null)
- return true;
- }
- break;
- }
- }
- return false;
- }
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevsExA")]
+ public static extern SafeHDEVINFO SetupDiGetClassDevsEx(in Guid ClassGuid, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string Enumerator,
+ [In, Optional] HWND hwndParent, DIGCF Flags, [In, Optional] HDEVINFO DeviceInfoSet,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
///
- /// The SetupDiGetDevicePropertyKeys function retrieves an array of the device property keys that represent the device
- /// properties that are set for a device instance.
+ /// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device
+ /// information elements for a local or a remote computer.
///
- ///
- /// A handle to a device information set. This device information set contains the device instance for which this function retrieves
- /// an array of device property keys. The property keys represent the device properties that are set for the device instance.
+ ///
+ /// A pointer to the GUID for a device setup class or a device interface class. This pointer is optional and can be NULL. If
+ /// a GUID value is not used to select devices, set ClassGuid to NULL. For more information about how to use ClassGuid, see
+ /// the following Remarks section.
///
- ///
- /// A pointer to an SP_DEVINFO_DATA structure that represents the device instance for which to retrieve the requested array of
- /// device property keys.
- ///
- ///
- /// A pointer to a buffer that receives an array of DEVPROPKEY-typed values, where each value is a device property key that
- /// represents a device property that is set for the device instance. The pointer is optional and can be NULL. For more
- /// information, see the Remarks section later in this topic.
- ///
- ///
- /// The size, in DEVPROPKEY-typed values, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL,
- /// PropertyKeyCount must be set to zero.
- ///
- ///
- /// A pointer to a DWORD-typed variable that receives the number of requested device property keys. The pointer is optional and can
- /// be set to NULL.
- ///
- /// This parameter must be set to zero.
- ///
- ///
- /// SetupDiGetDevicePropertyKeys returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
- /// error can be retrieved by calling GetLastError.
- ///
- /// The following table includes some of the more common error codes that this function might log.
- ///
- ///
- /// Return code
- /// Description
- ///
+ ///
+ /// A pointer to a NULL-terminated string that specifies:
+ ///
/// -
- /// ERROR_INVALID_FLAGS
- /// The value of Flags is not zero.
+ ///
+ /// An identifier (ID) of a Plug and Play (PnP) enumerator. This ID can either be the enumerator's globally unique identifier (GUID)
+ /// or symbolic name. For example, "PCI" can be used to specify the PCI PnP enumerator. Other examples of symbolic names for PnP
+ /// enumerators include "USB", "PCMCIA", and "SCSI".
+ ///
///
/// -
- /// ERROR_INVALID_HANDLE
- /// The device information set that is specified by DevInfoSet is not valid.
- ///
- /// -
- /// ERROR_INVALID_PARAMETER
- /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
- ///
- /// -
- /// ERROR_INVALID_DATA
- /// An internal data value is not valid.
- ///
- /// -
- /// ERROR_INVALID_USER_BUFFER
- /// A user buffer is not valid. One possibility is that PropertyKeyArray is NULL and PropertKeyCount is not zero.
- ///
- /// -
- /// ERROR_NO_SUCH_DEVINST
- /// The device instance that is specified by DevInfoData does not exist.
- ///
- /// -
- /// ERROR_INSUFFICIENT_BUFFER
- /// The PropertyKeyArray buffer is too small to hold all the requested property keys.
- ///
- /// -
- /// ERROR_NOT_ENOUGH_MEMORY
- /// There was not enough system memory available to complete the operation.
+ /// A PnP device instance IDs. When specifying a PnP device instance ID, DIGCF_DEVICEINTERFACE must be set in the Flags parameter.
///
///
+ /// This pointer is optional and can be
+ /// NULL
+ /// . If an
+ /// Enumerator
+ /// value is not used to select devices, set
+ /// Enumerator
+ /// to
+ /// NULL
+ /// For more information about how to set the Enumerator value, see the following Remarks section.
+ ///
+ ///
+ /// A handle to the top-level window to be used for a user interface that is associated with installing a device instance in the
+ /// device information set. This handle is optional and can be NULL.
+ ///
+ ///
+ ///
+ /// A variable of type DWORD that specifies control options that filter the device information elements that are added to the device
+ /// information set. This parameter can be a bitwise OR of one or more of the following flags. For more information about combining
+ /// these control options, see the following Remarks section.
+ ///
+ /// DIGCF_ALLCLASSES
+ /// Return a list of installed devices for the specified device setup classes or device interface classes.
+ /// DIGCF_DEVICEINTERFACE
+ ///
+ /// Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags
+ /// parameter if the Enumerator parameter specifies a device instance ID.
+ ///
+ /// DIGCF_DEFAULT
+ ///
+ /// Return only the device that is associated with the system default device interface, if one is set, for the specified device
+ /// interface classes.
+ ///
+ /// DIGCF_PRESENT
+ /// Return only devices that are currently present.
+ /// DIGCF_PROFILE
+ /// Return only devices that are a part of the current hardware profile.
+ ///
+ ///
+ /// The handle to an existing device information set to which SetupDiGetClassDevsEx adds the requested device information
+ /// elements. This parameter is optional and can be set to NULL. For more information about using this parameter, see the
+ /// following Remarks section.
+ ///
+ ///
+ /// A pointer to a constant string that contains the name of a remote computer on which the devices reside. A value of NULL
+ /// for MachineName specifies that the device is installed on the local computer.
+ ///
+ /// Reserved for internal use. This parameter must be set to NULL.
+ ///
+ /// If the operation succeeds, SetupDiGetClassDevsEx returns a handle to a device information set that contains all installed
+ /// devices that matched the supplied parameters. If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended
+ /// error information, call GetLastError.
///
///
- /// SetupDiGetDevicePropertyKeys is part of the unified device property model.
///
- /// If the ProperKeyArray buffer is not large enough to hold all the requested property keys, SetupDiGetDevicePropertyKeys
- /// does not retrieve any property keys and returns ERROR_INSUFFICIENT_BUFFER. If the caller supplied a RequiredPropertyKeyCount
- /// pointer, SetupDiGetDevicePropertyKeys sets the value of *RequiredPropertyKeyCount to the required size, in
- /// DEVPROPKEY-typed values, of the PropertyKeyArray buffer.
+ /// The caller of SetupDiGetClassDevsEx must delete the returned device information set when it is no longer needed by
+ /// calling SetupDiDestroyDeviceInfoList.
+ ///
+ ///
+ /// If DeviceInfoSet is NULL, SetupDiGetClassDevsEx creates a new device information set that contains the retrieved
+ /// device information elements and returns a handle to the new device information set. If the caller requests that the function
+ /// retrieve devices for a device setup class that is supplied by the ClassGuid parameter, the function sets the device setup class
+ /// of the new device information set to the supplied class GUID.
+ ///
+ ///
+ /// If DeviceInfoSet is not set to NULL, the function adds the retrieved device information elements to the device
+ /// information set that is associated with the supplied handle, and returns the supplied handle. If ClassGuid supplies a device
+ /// setup class, the device setup class of the supplied device information set must be set to the supplied class GUID.
+ ///
+ /// Device Setup Class Control Options
+ ///
+ /// Use the following filtering options to control whether SetupDiGetClassDevsEx returns devices for all device setup classes
+ /// or only for a specified device setup class:
+ ///
+ ///
+ /// -
+ /// To return devices for all device setup classes, set the DIGCF_ALLCLASSES flag and set the ClassGuid parameter to NULL.
+ ///
+ /// -
+ ///
+ /// To return devices only for a specific device setup class, do not set DIGCF_ALLCLASSES and use ClassGuid to supply the GUID of
+ /// the device setup class.
+ ///
+ ///
+ ///
+ /// In addition, you can use the following filtering options to further restrict which devices are returned.
+ ///
+ /// -
+ /// To return only devices that are present in the system, set the DIGCF_PRESENT flag.
+ ///
+ /// -
+ /// To return only devices that are part of the current hardware profile, set the DIGCF_PROFILE flag.
+ ///
+ /// -
+ ///
+ /// To return devices for a specific PnP enumerator only, use the Enumerator parameter to supply the GUID or symbolic name of the
+ /// enumerator. If Enumerator is NULL, SetupDiGetClassDevsEx returns devices for all PnP enumerators.
+ ///
+ ///
+ ///
+ /// Device Interface Class Control Options
+ ///
+ /// Use the following filtering options to control whether SetupDiGetClassDevsEx returns devices that support any device
+ /// interface class or only devices that support a specified device interface class:
+ ///
+ ///
+ /// -
+ ///
+ /// To return devices that support a device interface of any class, set the DIGCF_DEVICEINTERFACE flag, set the DIGCF_ALLCLASSES
+ /// flag, and set ClassGuid to NULL. The function adds to the device information set a device information element that
+ /// represents such a device, and then adds to the device information element a device interface list that contains all the device
+ /// interfaces that the device supports.
+ ///
+ ///
+ /// -
+ ///
+ /// To return only devices that support a device interface of a specified class, set the DIGCF_DEVICEINTERFACE flag and use the
+ /// ClassGuid parameter to supply the class GUID of the device interface class. The function adds to the device information set a
+ /// device information element that represents such a device, and then adds a device interface of the specified class to the device
+ /// interface list for that device information element.
+ ///
+ ///
+ ///
+ ///
+ /// In addition, you can use the following filtering options to control whether SetupDiGetClassDevsEx returns only devices
+ /// that support the system default interface for device interface classes:
+ ///
+ ///
+ /// -
+ ///
+ /// To return only the device that supports the system default interface, if one is set, for a specified device interface class, set
+ /// the DIGCF_DEVICEINTERFACE flag, set the DIGCF_DEFAULT flag, and use ClassGuid to supply the class GUID of the device interface
+ /// class. The function adds to the device information set a device information element that represents such a device, and then adds
+ /// the system default interface to the device interface list for that device information element.
+ ///
+ ///
+ /// -
+ ///
+ /// To return a device that supports a system default interface for an unspecified device interface class, set the
+ /// DIGCF_DEVICEINTERFACE flag, set the DIGCF_ALLCLASSES flag, set the DIGCF_DEFAULT flag, and set ClassGuid to NULL. The
+ /// function adds to the device information set a device information element that represents such a device, and then adds the system
+ /// default interface to the device interface list for that device information element.
+ ///
+ ///
+ ///
+ /// You can also use the following options in combination with the other options to further restrict which devices are returned.
+ ///
+ /// -
+ /// To return only devices that are present in the system, set the DIGCF_PRESENT flag.
+ ///
+ /// -
+ /// To return only devices that are part of the current hardware profile, set the DIGCF_PROFILE flag.
+ ///
+ /// -
+ ///
+ /// To return only a specific device, set the DIGCF_DEVICEINTERFACE flag and use the Enumerator parameter to supply the device
+ /// instance ID of the device. To include all possible devices, set Enumerator to NULL.
+ ///
+ ///
+ ///
+ /// Retrieving Devices in a Device Setup Class That Support a Device Interface Class
+ ///
+ /// An installer can use SetupDiGetClassDevsEx to retrieve a list of devices of a particular device setup class that support
+ /// a device interface of a specified device interface class. For example, to retrieve a list of all devices on a local computer
+ /// that support a device interface in the "mounted device" interface class and that are members of the "Volume" device setup class,
+ /// an installer should perform the following operations:
+ ///
+ ///
+ /// -
+ ///
+ /// Call SetupDiCreateDeviceInfoList to create an empty device information set for the "Volume" device setup class. Set ClassGuid to
+ /// a pointer to the class GUID for the "Volume" device setup class and set hwndParent as appropriate. In response to such a call,
+ /// the function will return a handle to type HDEVINFO to the device information set.
+ ///
+ ///
+ /// -
+ /// Call SetupDiGetClassDevsEx with the following settings:
+ ///
+ ///
+ ///
+ /// In an operation of this type, SetupDiGetClassDevsEx returns a device if the device setup class of the device is the same
+ /// as the supplied device information set and if the device supports a device interface whose class is the same as the specified
+ /// device interface class.
///
- /// To retrieve a device instance property, call SetupDiGetDeviceProperty, and to set a device instance property, call SetupDiSetDeviceProperty.
///
- // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdevicepropertykeys WINSETUPAPI BOOL
- // SetupDiGetDevicePropertyKeys( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DEVPROPKEY *PropertyKeyArray, DWORD
- // PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags );
- [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
- [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyKeys")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool SetupDiGetDevicePropertyKeys(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
- [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] DEVPROPKEY[] PropertyKeyArray, uint PropertyKeyCount,
- out uint RequiredPropertyKeyCount, uint Flags = 0);
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdevsexa WINSETUPAPI HDEVINFO
+ // SetupDiGetClassDevsExA( const GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags, HDEVINFO DeviceInfoSet, PCSTR
+ // MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevsExA")]
+ public static extern SafeHDEVINFO SetupDiGetClassDevsEx([In, Optional] IntPtr ClassGuid, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string Enumerator,
+ [In, Optional] HWND hwndParent, DIGCF Flags, [In, Optional] HDEVINFO DeviceInfoSet,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
- /*
- SetupDiAskForOEMDisk
- SetupDiBuildClassInfoList
- SetupDiBuildClassInfoListExA
- SetupDiBuildClassInfoListExW
- SetupDiBuildDriverInfoList
- SetupDiCallClassInstaller
- SetupDiCancelDriverInfoSearch
- SetupDiChangeState
- SetupDiClassGuidsFromNameA
- SetupDiClassGuidsFromNameExA
- SetupDiClassGuidsFromNameExW
- SetupDiClassGuidsFromNameW
- SetupDiClassNameFromGuidExA
- SetupDiClassNameFromGuidExW
- SetupDiCreateDeviceInfoA
- SetupDiCreateDeviceInfoList
- SetupDiCreateDeviceInfoListExA
- SetupDiCreateDeviceInfoListExW
- SetupDiCreateDeviceInfoW
- SetupDiCreateDeviceInterfaceA
- SetupDiCreateDeviceInterfaceRegKeyA
- SetupDiCreateDeviceInterfaceRegKeyW
- SetupDiCreateDeviceInterfaceW
- SetupDiCreateDevRegKeyA
- SetupDiCreateDevRegKeyW
- SetupDiDeleteDeviceInfo
- SetupDiDeleteDeviceInterfaceData
- SetupDiDeleteDeviceInterfaceRegKey
- SetupDiDeleteDevRegKey
- SetupDiDestroyClassImageList
- SetupDiDestroyDriverInfoList
- SetupDiDrawMiniIcon
- SetupDiEnumDriverInfoA
- SetupDiEnumDriverInfoW
- SetupDiGetActualModelsSectionA
- SetupDiGetActualModelsSectionW
- SetupDiGetActualSectionToInstallA
- SetupDiGetActualSectionToInstallExA
- SetupDiGetActualSectionToInstallExW
- SetupDiGetActualSectionToInstallW
- SetupDiGetClassBitmapIndex
- SetupDiGetClassDescriptionA
- SetupDiGetClassDescriptionExA
- SetupDiGetClassDescriptionExW
- SetupDiGetClassDescriptionW
- SetupDiGetClassDevPropertySheetsA
- SetupDiGetClassDevPropertySheetsW
- SetupDiGetClassDevsExA
- SetupDiGetClassDevsExW
- SetupDiGetClassImageIndex
- SetupDiGetClassImageList
- SetupDiGetClassImageListExA
- SetupDiGetClassImageListExW
- SetupDiGetClassInstallParamsA
- SetupDiGetClassInstallParamsW
- SetupDiGetClassPropertyExW
- SetupDiGetClassPropertyKeys
- SetupDiGetClassPropertyKeysExW
- SetupDiGetClassPropertyW
- SetupDiGetClassRegistryPropertyA
- SetupDiGetClassRegistryPropertyW
- SetupDiGetCustomDevicePropertyA
- SetupDiGetCustomDevicePropertyW
- SetupDiGetDeviceInfoListClass
- SetupDiGetDeviceInfoListDetailA
- SetupDiGetDeviceInfoListDetailW
- SetupDiGetDeviceInstallParamsA
- SetupDiGetDeviceInstallParamsW
- SetupDiGetDeviceInstanceIdA
- SetupDiGetDeviceInstanceIdW
- SetupDiGetDeviceInterfaceAlias
- SetupDiGetDeviceInterfacePropertyKeys
- SetupDiGetDeviceInterfacePropertyW
- SetupDiGetDevicePropertyKeys
- SetupDiGetDeviceRegistryPropertyA
- SetupDiGetDeviceRegistryPropertyW
- SetupDiGetDriverInfoDetailA
- SetupDiGetDriverInfoDetailW
- SetupDiGetDriverInstallParamsA
- SetupDiGetDriverInstallParamsW
- SetupDiGetHwProfileFriendlyNameA
- SetupDiGetHwProfileFriendlyNameExA
- SetupDiGetHwProfileFriendlyNameExW
- SetupDiGetHwProfileFriendlyNameW
- SetupDiGetHwProfileList
- SetupDiGetHwProfileListExA
- SetupDiGetHwProfileListExW
- SetupDiGetINFClassA
- SetupDiGetINFClassW
- SetupDiGetSelectedDevice
- SetupDiGetSelectedDriverA
- SetupDiGetSelectedDriverW
- SetupDiInstallClassA
- SetupDiInstallClassExA
- SetupDiInstallClassExW
- SetupDiInstallClassW
- SetupDiInstallDevice
- SetupDiInstallDeviceInterfaces
- SetupDiInstallDriverFiles
- SetupDiLoadClassIcon
- SetupDiLoadDeviceIcon
- SetupDiOpenClassRegKey
- SetupDiOpenClassRegKeyExA
- SetupDiOpenClassRegKeyExW
- SetupDiOpenDeviceInfoA
- SetupDiOpenDeviceInfoW
- SetupDiOpenDeviceInterfaceA
- SetupDiOpenDeviceInterfaceRegKey
- SetupDiOpenDeviceInterfaceW
- SetupDiOpenDevRegKey
- SetupDiRegisterCoDeviceInstallers
- SetupDiRegisterDeviceInfo
- SetupDiRemoveDevice
- SetupDiRemoveDeviceInterface
- SetupDiRestartDevices
- SetupDiSelectBestCompatDrv
- SetupDiSelectDevice
- SetupDiSelectOEMDrv
- SetupDiSetClassInstallParamsA
- SetupDiSetClassInstallParamsW
- SetupDiSetClassPropertyExW
- SetupDiSetClassPropertyW
- SetupDiSetClassRegistryPropertyA
- SetupDiSetClassRegistryPropertyW
- SetupDiSetDeviceInstallParamsA
- SetupDiSetDeviceInstallParamsW
- SetupDiSetDeviceInterfaceDefault
- SetupDiSetDeviceInterfacePropertyW
- SetupDiSetDevicePropertyW
- SetupDiSetDeviceRegistryPropertyA
- SetupDiSetDeviceRegistryPropertyW
- SetupDiSetDriverInstallParamsA
- SetupDiSetDriverInstallParamsW
- SetupDiSetSelectedDevice
- SetupDiSetSelectedDriverA
- SetupDiSetSelectedDriverW
- SetupDiUnremoveDevice
- */
+ /// The SetupDiGetClassImageIndex function retrieves the index within the class image list of a specified class.
+ ///
+ /// A pointer to an SP_CLASSIMAGELIST_DATA structure that describes a class image list that includes the image for the device setup
+ /// class that is specified by the ClassGuid parameter.
+ ///
+ ///
+ /// A pointer to the GUID of the device setup class for which to retrieve the index of the class image in the specified class image list.
+ ///
+ ///
+ /// A pointer to an INT-typed variable that receives the index of the specified class image in the class image list.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ /// If the specified device setup class is not included in the specified class image list, SetupDiGetClassImageIndex returns
+ /// the image index for the Unknown device setup class in the ImageIndex parameter.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassimageindex WINSETUPAPI BOOL
+ // SetupDiGetClassImageIndex( PSP_CLASSIMAGELIST_DATA ClassImageListData, const GUID *ClassGuid, PINT ImageIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassImageIndex")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassImageIndex(in SP_CLASSIMAGELIST_DATA ClassImageListData, in Guid ClassGuid, out int ImageIndex);
+
+ ///
+ /// The SetupDiGetClassImageList function builds an image list that contains bitmaps for every installed class and returns
+ /// the list in a data structure.
+ ///
+ ///
+ /// A pointer to an SP_CLASSIMAGELIST_DATA structure to receive information regarding the class image list, including a handle to
+ /// the image list. The cbSize field of this structure must be initialized with the size of the structure, in bytes, before
+ /// calling this function or it will fail.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ /// The image list built by this function should be destroyed by calling SetupDiDestroyClassImageList.
+ /// Call SetupDiGetClassImageListEx to retrieve the image list for classes installed on a remote computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassimagelist WINSETUPAPI BOOL
+ // SetupDiGetClassImageList( PSP_CLASSIMAGELIST_DATA ClassImageListData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassImageList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassImageList(ref SP_CLASSIMAGELIST_DATA ClassImageListData);
+
+ ///
+ /// The SetupDiGetClassImageListEx function builds an image list of bitmaps for every class installed on a local or remote system.
+ ///
+ ///
+ /// A pointer to an SP_CLASSIMAGELIST_DATA structure to receive information regarding the class image list, including a handle to
+ /// the image list. The cbSize field of this structure must be initialized with the size of the structure, in bytes, before
+ /// calling this function or it will fail.
+ ///
+ ///
+ /// A pointer to NULL-terminated string that supplies the name of a remote system for whose classes SetupDiGetClassImageListEx
+ /// must build the bitmap. This parameter is optional and can be NULL. If MachineName is NULL,
+ /// SetupDiGetClassImageListEx builds the list for the local system.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ /// The image list built by this function should be destroyed by calling SetupDiDestroyClassImageList.
+ ///
+ /// Note Class-specific icons on a remote computer can only be displayed if the class is also present on the local computer.
+ /// Thus, if the remote computer has class X, but class X is not installed locally, then the generic (unknown) icon will be returned.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassimagelistexa WINSETUPAPI BOOL
+ // SetupDiGetClassImageListExA( PSP_CLASSIMAGELIST_DATA ClassImageListData, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassImageListExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassImageListEx(ref SP_CLASSIMAGELIST_DATA ClassImageListData,
+ [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiGetClassInstallParams function retrieves class installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to a device information set that contains the class install parameters to retrieve.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specified a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiGetClassInstallParams retrieves the class
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiGetClassInstallParams
+ /// retrieves the class install parameters for the global class driver list that is associated with DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to a buffer that contains an SP_CLASSINSTALL_HEADER structure. This structure must have its cbSize member set
+ /// to sizeof( SP_CLASSINSTALL_HEADER ) on input or the buffer is considered to be invalid. On output, the
+ /// InstallFunction member is filled with the device installation function code for the class installation parameters being
+ /// retrieved. If the buffer is large enough, it also receives the class installation parameters structure specific to the function
+ /// code. If ClassInstallParams is not specified, ClassInstallParamsSize must be 0.
+ ///
+ ///
+ /// The size, in bytes, of the ClassInstallParams buffer. If the buffer is supplied, it must be at least as large as sizeof(
+ /// SP_CLASSINSTALL_HEADER ). If the buffer is not supplied, ClassInstallParamsSize must be 0.
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the number of bytes required to store the class install parameters. This
+ /// parameter is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// The class install parameters are specific to a particular device installation function code that is stored in the
+ /// ClassInstallHeader field located at the beginning of the ClassInstallParams buffer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassinstallparamsa WINSETUPAPI BOOL
+ // SetupDiGetClassInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER
+ // ClassInstallParams, DWORD ClassInstallParamsSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [In, Optional] IntPtr ClassInstallParams, uint ClassInstallParamsSize, out uint RequiredSize);
}
}
\ No newline at end of file
diff --git a/PInvoke/SetupAPI/SetupAPI.DiFuncs2.cs b/PInvoke/SetupAPI/SetupAPI.DiFuncs2.cs
new file mode 100644
index 00000000..d949c2b5
--- /dev/null
+++ b/PInvoke/SetupAPI/SetupAPI.DiFuncs2.cs
@@ -0,0 +1,4890 @@
+using Microsoft.Win32.SafeHandles;
+using System;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Security.AccessControl;
+using System.Text;
+using Vanara.Extensions;
+using Vanara.InteropServices;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the SetupAPI.dll
+ public static partial class SetupAPI
+ {
+ ///
+ /// The SetupDiGetClassProperty function retrieves a device property that is set for a device setup class or a device
+ /// interface class.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the device setup class or device interface class for which to retrieve a device property
+ /// that is set for the device class. For information about specifying the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device class property.
+ ///
+ ///
+ /// A pointer to a DEVPROPTYPE-typed variable that receives the property-data-type identifier of the requested device class
+ /// 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 class property. SetupDiGetClassProperty retrieves the requested
+ /// property value 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, SetupDiGetClassProperty returns the size of the device class
+ /// property, in bytes, in *RequiredSize.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives either the size, in bytes, of the device class property if the device class
+ /// property is retrieved or the required buffer size if the buffer is not large enough. This pointer can be set to NULL.
+ ///
+ ///
+ /// One of the following values, which specifies whether the class is a device setup class or a device interface class.
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ ///
+ /// SetupDiGetClassProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error
+ /// can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// The device setup class that is specified by ClassGuid is not valid. This error can occur only if the DICLASSPROP_INSTALLER flag
+ /// is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// An unspecified parameter is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ /// The device interface reference string is not valid. This error can be returned if the DICLASSPROP_INTERFACE flag is specified.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified internal data value was not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// The device interface class that is specified by ClassGuid does not exist. This error can occur only if the DICLASSPROP_INTERFACE
+ /// flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// The requested device property does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetClassProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiGetClassProperty.
+ /// A caller of SetupDiGetClassProperty must be a member of the Administrators group to set a device interface property.
+ ///
+ /// To obtain the device property keys that represent the device properties that are set for a device class on a local computer,
+ /// call SetupDiGetClassPropertyKeys.
+ ///
+ /// To retrieve a device class property on a remote computer, call SetupDiGetClassPropertyEx.
+ ///
+ /// To set a device class property on a local computer, call SetupDiSetClassProperty , and to set a device class property on
+ /// a remote computer, call SetupDiSetClassPropertyEx.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclasspropertyw WINSETUPAPI BOOL
+ // SetupDiGetClassPropertyW( const GUID *ClassGuid, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer,
+ // DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassProperty(in Guid ClassGuid, in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType,
+ [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize, DICLASSPROP Flags);
+
+ ///
+ /// The SetupDiGetClassPropertyEx function retrieves a class property for a device setup class or a device interface class on
+ /// a local or remote computer.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the device setup class or device interface class for which to retrieve a device property for
+ /// the device class. For information about specifying the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device class property.
+ ///
+ ///
+ /// A pointer to a DEVPROPTYPE-typed variable that receives the property-data-type identifier of the requested device class
+ /// 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 class property. SetupDiGetClassPropertyEx retrieves the
+ /// requested property value 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, SetupDiGetClassPropertyEx returns the size of the
+ /// device class property, in bytes, in *RequiredSize.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives either the size, in bytes, of the device class 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.
+ ///
+ ///
+ /// One of the following values, which specifies whether the class is a device setup class or a device interface class:
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the UNC name, including the "\" prefix, of a computer. The pointer can be
+ /// set to NULL. If MachineName is NULL, SetupDiGetClassPropertyEx retrieves the requested device class
+ /// property from the local computer.
+ ///
+ /// This parameter must be set to NULL.
+ ///
+ ///
+ /// SetupDiGetClassPropertyEx returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// The device setup class that is specified by ClassGuid is not valid. This error can occur only if the DICLASSPROP_INSTALLER flag
+ /// is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// An unspecified parameter is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ /// The device interface reference string is not valid. This error can be returned if the DICLASSPROP_INTERFACE flag is specified.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified internal data value was not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_MACHINENAME
+ /// The computer name that is specified by MachineName is not valid.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// The device interface class that is specified by ClassGuid does not exist. This error can occur only if the DICLASSPROP_INTERFACE
+ /// flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// The requested device property does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetClassPropertyEx is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiGetClassPropertyEx.
+ /// A caller of SetupDiGetClassPropertyEx must be a member of the Administrators group to set a device interface property.
+ ///
+ /// To obtain the device property keys that represent the device properties that are set for a device class on a remote computer,
+ /// call SetupDiGetClassPropertyKeysEx.
+ ///
+ /// To retrieve a device class property on a local computer, call SetupDiGetClassProperty.
+ ///
+ /// To set a device class property on a local computer, call SetupDiSetClassProperty , and to set a device class property on
+ /// a remote computer, call SetupDiSetClassPropertyEx.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclasspropertyexw WINSETUPAPI BOOL
+ // SetupDiGetClassPropertyExW( const GUID *ClassGuid, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE
+ // PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags, PCWSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyExW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassPropertyEx(in Guid ClassGuid, in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType,
+ [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize, DICLASSPROP Flags,
+ [Optional, MarshalAs(UnmanagedType.LPWStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiGetClassPropertyKeys function retrieves an array of the device property keys that represent the device
+ /// properties that are set for a device setup class or a device interface class.
+ ///
+ ///
+ /// A pointer to a GUID that represents a device setup class or a device interface class. SetupDiGetClassPropertyKeys
+ /// retrieves an array of the device property keys that represent device properties that are set for the specified class. For
+ /// information about specifying the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a buffer that receives an array of DEVPROPKEY-typed values, where each value is a device property key that
+ /// represents a device property that is set for the device class. The pointer is optional and can be NULL. For more
+ /// information, see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in DEVPROPKEY-typed values, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL,
+ /// PropertyKeyCount must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of requested property keys. The parameter is optional and can be
+ /// set to NULL.
+ ///
+ ///
+ ///
+ /// One of the following values, which specifies whether to retrieve property keys for a device setup class or for a device
+ /// interface class:
+ ///
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ ///
+ /// SetupDiGetClassPropertyKeys returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// If the DICLASSPROP_INSTALLER flag is specified, this error code indicates that the device setup class that is specified by
+ /// ClassGuid does not exist.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ ///
+ /// The reference string for the device interface that is specified by ClassGuild is not valid. This error can be returned if the
+ /// DICLASSPROP_INTERFACE flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified data value is not valid. One possibility is that the ClassGuid value is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// An unspecified parameter is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyKeyArray is NULL, and PropertKeyCount is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// If the DICLASSPROP_INTERFACE flag is specified, this error code indicates that the device interface class that is specified by
+ /// ClassGuid does not exist.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICENT_BUFFER
+ ///
+ /// The PropertyKeyArray buffer is not large enough to hold all the property keys, or an internal data buffer that was passed to a
+ /// system call was too small.
+ ///
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetClassPropertyKeys is part of the unified device property model.
+ ///
+ /// A caller of SetupDiGetClassPropertyKeys must be a member of the Administrators group to retrieve device property keys for
+ /// a device class.
+ ///
+ ///
+ /// If the PropertyKeyArray buffer is not large enough to hold all the requested property keys, SetupDiGetClassPropertyKeys
+ /// does not retrieve any property keys and returns ERROR_INSUFFICIENT_BUFFER. If the caller supplied a RequiredPropertyKeyCount
+ /// pointer, SetupDiGetClassPropertyKeys sets the value of *RequiredPropertyKeyCount to the required size, in
+ /// DEVPROPKEY-typed values, of the PropertyKeyArray buffer.
+ ///
+ ///
+ /// To retrieve a device class property on a local computer, call SetupDiGetClassProperty. To set a device class property on a local
+ /// computer, call SetupDiSetClassProperty.
+ ///
+ /// To retrieve the property keys for a device setup class or device interface class on a remote computer, call SetupDiGetClassPropertyKeysEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclasspropertykeys WINSETUPAPI BOOL
+ // SetupDiGetClassPropertyKeys( const GUID *ClassGuid, DEVPROPKEY *PropertyKeyArray, DWORD PropertyKeyCount, PDWORD
+ // RequiredPropertyKeyCount, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyKeys")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassPropertyKeys(in Guid ClassGuid,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[] PropertyKeyArray, uint PropertyKeyCount,
+ out uint RequiredPropertyKeyCount, DICLASSPROP Flags);
+
+ ///
+ /// The SetupDiGetClassPropertyKeysEx function retrieves an array of the device property keys that represent the device
+ /// properties that are set for a device setup class or a device interface class on a local or a remote computer.
+ ///
+ ///
+ /// A pointer to a GUID that represents a device setup class or a device interface class. SetupDiGetClassPropertyKeysEx
+ /// retrieves an array of the device property keys that represent device properties that are set for the specified class. For
+ /// information about specifying the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a buffer that receives an array of DEVPROPKEY-typed values, where each value is a device property key that
+ /// represents a device property that is set for the device setup class. The pointer is optional and can be NULL. For more
+ /// information, see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in DEVPROPKEY-type values, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL, PropertyKeyCount
+ /// must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of requested property keys. The pointer is optional and can be set
+ /// to NULL.
+ ///
+ ///
+ ///
+ /// One of the following values, which specifies whether to retrieve class property keys for a device setup class or for a device
+ /// interface class.
+ ///
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the UNC name, including the "\" prefix, of a computer. The pointer can be
+ /// NULL. If the pointer is NULL, SetupDiGetClassPropertyKeysEx retrieves the requested information from the
+ /// local computer.
+ ///
+ /// This parameter must be set to NULL.
+ ///
+ ///
+ /// SetupDiGetClassPropertyKeysEx returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// If the DICLASSPROP_INSTALLER flag is specified, this error code indicates that the device setup class that is specified by
+ /// ClassGuid does not exist.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ ///
+ /// The reference string for the device interface that is specified by ClassGuild is not valid. This error might be returned when
+ /// the DICLASSPROP_INTERFACE flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified data value is not valid. One possibility is that the ClassGuid value is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// An unspecified parameter is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyKeyArray is NULL, and PropertKeyCount is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_MACHINENAME
+ /// The computer name that is specified by MachineName is not valid.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// If the DICLASSPROP_INTERFACE flag is specified, this error code indicates that the device interface class that is specified by
+ /// ClassGuid does not exist.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICENT_BUFFER
+ ///
+ /// The PropertyKeyArray buffer is not large enough to hold all the property keys, or an internal data buffer that was passed to a
+ /// system call was too small.
+ ///
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetClassPropertyKeysEx is part of the unified device property model.
+ ///
+ /// A caller of SetupDiGetClassPropertyKeysEx must be a member of the Administrators group to retrieve device property keys
+ /// for a device class.
+ ///
+ ///
+ /// If the PropertyKeyArray buffer is not large enough to hold all the requested property keys, SetupDiGetClassPropertyKeysEx
+ /// does not retrieve any property keys and returns ERROR_INSUFFICIENT_BUFFER. If the caller supplied a RequiredPropertyKeyCount
+ /// pointer, SetupDiGetClassPropertyKeysEx sets the value of *RequiredPropertyKeyCount to the required size, in
+ /// DEVPROPKEY-typed values, of the PropertyKeyArray buffer.
+ ///
+ ///
+ /// To retrieve a device class property on a remote computer, call SetupDiGetClassPropertyEx, and to set a device class property on
+ /// a remote computer, call SetupDiSetClassPropertyEx.
+ ///
+ /// To retrieve the property keys for a device setup class or device interface class on a local computer, call SetupDiGetClassPropertyKeys.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclasspropertykeysexw WINSETUPAPI BOOL
+ // SetupDiGetClassPropertyKeysExW( const GUID *ClassGuid, DEVPROPKEY *PropertyKeyArray, DWORD PropertyKeyCount, PDWORD
+ // RequiredPropertyKeyCount, DWORD Flags, PCWSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyKeysExW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassPropertyKeysEx(in Guid ClassGuid,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[] PropertyKeyArray, uint PropertyKeyCount,
+ out uint RequiredPropertyKeyCount, DICLASSPROP Flags, [Optional, MarshalAs(UnmanagedType.LPWStr)] string MachineName,
+ [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiGetClassRegistryProperty function retrieves a property for a specified device setup class from the registry.
+ ///
+ /// A pointer to a GUID representing the device setup class for which a property is to be retrieved.
+ ///
+ /// A value that identifies the property to be retrieved. This must be one of the following values:
+ /// SPCRP_CHARACTERISTICS
+ ///
+ /// The function returns flags indicating device characteristics for the class. For a list of characteristics flags, see the
+ /// DeviceCharacteristics parameter to IoCreateDevice.
+ ///
+ /// SPCRP_DEVTYPE
+ ///
+ /// The function returns a DWORD value that represents the device type for the class. For more information, see Specifying Device Types.
+ ///
+ /// SPCRP_EXCLUSIVE
+ ///
+ /// The function returns a DWORD value indicating whether users can obtain exclusive access to devices for this class. The returned
+ /// value is one if exclusive access is allowed, or zero otherwise.
+ ///
+ /// SPCRP_LOWERFILTERS
+ ///
+ /// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the lower filter drivers that are
+ /// installed for the device setup class.
+ ///
+ /// SPCRP_SECURITY
+ ///
+ /// The function returns the device's security descriptor as a SECURITY_DESCRIPTOR structure in self-relative format (described in
+ /// the Microsoft Windows SDK documentation).
+ ///
+ /// SPCRP_SECURITY_SDS
+ ///
+ /// The function returns the device's security descriptor as a text string. For information about security descriptor strings, see
+ /// Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings, see Security
+ /// Descriptor Definition Language (Windows).
+ ///
+ /// SPCRP_UPPERFILTERS
+ ///
+ /// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the upper filter drivers that are
+ /// installed for the device setup class.
+ ///
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the property data type as one of the REG_-prefixed registry data types. This
+ /// parameter is optional and can be NULL. If this parameter is NULL, S etupDiGetClassRegistryProperty does not
+ /// return the data type.
+ ///
+ /// A pointer to a buffer that receives the requested property.
+ /// The size, in bytes, of the PropertyBuffer buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer. If the
+ /// PropertyBuffer buffer is too small, and RequiredSize is not NULL, the function sets RequiredSize to the minimum buffer
+ /// size that is required to receive the requested property.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote system from which to retrieve the specified device
+ /// class property. This parameter is optional and can be NULL. If this parameter is NULL, the property is retrieved
+ /// from the local system.
+ ///
+ /// Reserved, must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetclassregistrypropertya WINSETUPAPI BOOL
+ // SetupDiGetClassRegistryPropertyA( const GUID *ClassGuid, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD
+ // PropertyBufferSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassRegistryPropertyA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetClassRegistryProperty(in Guid ClassGuid, SPCRP Property, out REG_VALUE_TYPE PropertyRegDataType,
+ [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize,
+ [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiGetCustomDeviceProperty function retrieves a specified custom device property from the registry.
+ ///
+ /// A handle to the device information set that contains a device information element that represents the device for which to
+ /// retrieve a custom device property.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ /// A registry value name representing a custom property.
+ ///
+ /// A flag value that indicates how the requested information should be returned. The flag can be zero or one of the following:
+ /// DICUSTOMDEVPROP_MERGE_MULTISZ
+ ///
+ /// If set, the function retrieves both device instance-specific property values and hardware ID-specific property values,
+ /// concatenated as a REG_MULTI_SZ-typed string. (For more information, see the Remarks section on this reference page.)
+ ///
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the data type of the retrieved property. The data type is specified as one
+ /// of the REG_-prefixed constants that represents registry data types. This parameter is optional and can be NULL.
+ ///
+ /// A pointer to a buffer that receives requested property information.
+ /// The size, in bytes, of the PropertyBuffer buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the buffer size, in bytes, that is required to receive the requested
+ /// information. This parameter is optional and can be NULL. If this parameter is specified,
+ /// SetupDiGetCustomDeviceProperty returns the required size, regardless of whether the PropertyBuffer buffer is large enough
+ /// to receive the requested information.
+ ///
+ ///
+ /// If the operation succeeds, SetupDiGetCustomDeviceProperty returns TRUE. Otherwise, the function returns
+ /// FALSE and the logged error can be retrieved with a call to GetLastError. If the PropertyBuffer buffer is not large enough
+ /// to receive the requested information, SetupDiGetCustomDeviceProperty returns FALSE and a subsequent call to
+ /// GetLastError will return ERROR_INSUFFICIENT_BUFFER.
+ ///
+ ///
+ ///
+ /// SetupDiGetCustomDeviceProperty retrieves device properties that are associated with a single device instance or with all
+ /// devices matching a certain hardware ID. (For information about hardware IDs, see Device Identification Strings).
+ ///
+ ///
+ /// Vendors can set properties for a device instance by using INF AddReg directives in INF DDInstall.HW sections and specifying the
+ /// HKR registry root.
+ ///
+ /// Only the system can set properties for hardware IDs. The system supplies an "Icon" property for some hardware IDs.
+ ///
+ /// The function first checks to see if the specified property exists for the specified device instance. If so, the property's value
+ /// is returned. If not, the function checks to see if the property exists for all devices matching the hardware ID of the specified
+ /// device instance. If so, the property's value is returned. If DICUSTOMDEVPROP_MERGE_MULTISZ is set in Flags, the function returns
+ /// the property values associated with both the device instance and the hardware ID, if they both exist.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetcustomdevicepropertya WINSETUPAPI BOOL
+ // SetupDiGetCustomDevicePropertyA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PCSTR CustomPropertyName, DWORD Flags,
+ // PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetCustomDevicePropertyA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetCustomDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [MarshalAs(UnmanagedType.LPTStr)] string CustomPropertyName, DICUSTOMDEVPROP Flags, out REG_VALUE_TYPE PropertyRegDataType,
+ [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetDeviceInfoListClass function retrieves the GUID for the device setup class associated with a device
+ /// information set if the set has an associated class.
+ ///
+ /// A handle to the device information set to query.
+ /// A pointer to variable of type GUID that receives the GUID for the associated class.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the specified device information set does not have an associated class because a class GUID was not specified when the set
+ /// was created with SetupDiCreateDeviceInfoList, the function fails. In this case, a call to GetLastError returns ERROR_NO_ASSOCIATED_CLASS.
+ ///
+ ///
+ /// If a device information set is for a remote computer, use SetupDiGetDeviceInfoListDetail to get the associated remote computer
+ /// handle and computer name.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinfolistclass WINSETUPAPI BOOL
+ // SetupDiGetDeviceInfoListClass( HDEVINFO DeviceInfoSet, LPGUID ClassGuid );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInfoListClass")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInfoListClass(HDEVINFO DeviceInfoSet, out Guid ClassGuid);
+
+ ///
+ /// The SetupDiGetDeviceInfoListDetail function retrieves information associated with a device information set including the
+ /// class GUID, remote computer handle, and remote computer name.
+ ///
+ /// A handle to the device information set for which to retrieve information.
+ ///
+ /// A pointer to a caller-initialized SP_DEVINFO_LIST_DETAIL_DATA structure that receives the device information set information.
+ /// For more information about this structure, see the following Remarks section.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the parameters are valid, SetupDiGetDeviceInfoListDetail sets values in the DeviceInfoSetDetailData structure (except
+ /// for the cbSize field) and returns status NO_ERROR.
+ ///
+ ///
+ /// A caller of SetupDiGetDeviceInfoListDetail must set DeviceInfoSetDetailData. cbSize to
+ /// sizeof(SP_DEVINFO_LIST_DETAIL_DATA) or the function will fail and the call to GetLastError will return ERROR_INVALID_USER_BUFFER.
+ ///
+ ///
+ /// If SetupDiGetDeviceInfoListDetail completes successfully, DeviceInfoSetDetailData. ClassGuid contains the class
+ /// GUID associated with the device information set or a GUID_NULL structure.
+ ///
+ ///
+ /// If SetupDiGetDeviceInfoListDetail completes successfully and the device information set is for a remote system,
+ /// DeviceInfoSetDetailData. RemoteMachineHandle contains the ConfigMgr32 system handle for accessing the remote system and
+ /// DeviceInfoSetDetailData. RemoteMachineName contains the name of the remote system. If there is a remote handle for the
+ /// device information set, it must be used when calling CM_ Xxx _Ex functions because the DevInst handles are
+ /// relative to the remote handle.
+ ///
+ ///
+ /// If the device information set is for the local computer, DeviceInfoSetDetailData. RemoteMachineHandle is NULL and
+ /// DeviceInfoSetDetailData. RemoteMachineName is an empty string.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinfolistdetaila WINSETUPAPI BOOL
+ // SetupDiGetDeviceInfoListDetailA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInfoListDetailA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInfoListDetail(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_LIST_DETAIL_DATA DeviceInfoSetDetailData);
+
+ ///
+ /// The SetupDiGetDeviceInstallParams function retrieves device installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set that contains the device installation parameters to retrieve.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiGetDeviceInstallParams retrieves the installation
+ /// parameters for the specified device. If this parameter is NULL, the function retrieves the global device installation
+ /// parameters that are associated with DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DEVINSTALL_PARAMS structure that receives the device install parameters. DeviceInstallParams. cbSize
+ /// must be set to the size, in bytes, of the structure before calling this function.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinstallparamsa WINSETUPAPI BOOL
+ // SetupDiGetDeviceInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A
+ // DeviceInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, ref SP_DEVINSTALL_PARAMS DeviceInstallParams);
+
+ ///
+ /// The SetupDiGetDeviceInstallParams function retrieves device installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set that contains the device installation parameters to retrieve.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiGetDeviceInstallParams retrieves the installation
+ /// parameters for the specified device. If this parameter is NULL, the function retrieves the global device installation
+ /// parameters that are associated with DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DEVINSTALL_PARAMS structure that receives the device install parameters. DeviceInstallParams. cbSize
+ /// must be set to the size, in bytes, of the structure before calling this function.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinstallparamsa WINSETUPAPI BOOL
+ // SetupDiGetDeviceInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A
+ // DeviceInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInstallParams(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, ref SP_DEVINSTALL_PARAMS DeviceInstallParams);
+
+ ///
+ /// The SetupDiGetDeviceInstanceId function retrieves the device instance ID that is associated with a device information element.
+ ///
+ ///
+ /// A handle to the device information set that contains the device information element that represents the device for which to
+ /// retrieve a device instance ID.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// A pointer to the character buffer that will receive the NULL-terminated device instance ID for the specified device information
+ /// element. For information about device instance IDs, see Device Identification Strings.
+ ///
+ /// The size, in characters, of the DeviceInstanceId buffer.
+ ///
+ /// A pointer to the variable that receives the number of characters required to store the device instance ID.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinstanceida WINSETUPAPI BOOL
+ // SetupDiGetDeviceInstanceIdA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSTR DeviceInstanceId, DWORD
+ // DeviceInstanceIdSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInstanceIdA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInstanceId(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder DeviceInstanceId, uint DeviceInstanceIdSize, out uint RequiredSize);
+
+ /// The SetupDiGetDeviceInterfaceAlias function returns an alias of a specified device interface.
+ ///
+ /// A pointer to the device information set that contains the device interface for which to retrieve an alias. This handle is
+ /// typically returned by SetupDiGetClassDevs.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet for which to retrieve an
+ /// alias. This pointer is typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ /// A pointer to a GUID that specifies the interface class of the alias to retrieve.
+ ///
+ /// A pointer to a caller-allocated buffer that contains, on successful return, a completed SP_DEVICE_INTERFACE_DATA structure that
+ /// identifies the requested alias. The caller must set AliasDeviceInterfaceData .cbSize to
+ /// sizeof(SP_DEVICE_INTERFACE_DATA) before calling this function.
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceAlias returns TRUE if the function completed without error. If the function completed
+ /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ /// Possible errors returned by GetLastError are listed in the following table.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// Invalid DeviceInfoSet or invalid DeviceInterfaceData parameter.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_DEVICE
+ /// There is no alias of class AliasInterfaceClassGuid for the specified device interface.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// Invalid AliasDeviceInterfaceData buffer.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Device interfaces are considered aliases if they are of different interface classes but are supported by the same device and
+ /// have identical reference strings.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceAlias can be used to locate a device that exposes more than one interface. For example, consider
+ /// a disk that can be part of a fault-tolerant volume and can contain encrypted data. The function driver for the disk device could
+ /// register a fault-tolerant-volume interface and an encrypted-volume interface. These interfaces are device interface aliases if
+ /// the function driver registers them with identical reference strings and they refer to the same device. (The reference strings
+ /// will likely be NULL and therefore are equal.)
+ ///
+ ///
+ /// To locate such a multi-interface device, first locate all available devices that expose one of the interfaces, such as the
+ /// fault-tolerant-volume interface, using SetupDiGetClassDevs and SetupDiEnumDeviceInterfaces. Then, pass a device with the first
+ /// interface (fault-tolerant-volume) to SetupDiGetDeviceInterfaceAlias and request an alias of the other interface class (encrypted-volume).
+ ///
+ ///
+ /// If the requested alias exists but the caller-supplied AliasDeviceInterfaceData buffer is invalid, this function successfully
+ /// adds the device interface element to DevInfoSet but returns FALSE for the return value. In this case, GetLastError
+ /// returns ERROR_INVALID_USER_BUFFER.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacealias WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfaceAlias( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, const GUID
+ // *AliasInterfaceClassGuid, PSP_DEVICE_INTERFACE_DATA AliasDeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceAlias")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInterfaceAlias(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ in Guid AliasInterfaceClassGuid, ref SP_DEVICE_INTERFACE_DATA AliasDeviceInterfaceData);
+
+ /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
+ ///
+ /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
+ /// returned by SetupDiGetClassDevs.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details.
+ /// A pointer of this type is typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure to receive information about the specified interface. This parameter
+ /// is optional and can be NULL. This parameter must be NULL if DeviceInterfaceDetailSize is zero. If this parameter
+ /// is specified, the caller must set DeviceInterfaceDetailData .cbSize to sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
+ /// before calling this function. The cbSize member always contains the size of the fixed part of the data structure, not a
+ /// size reflecting the variable-length string at the end.
+ ///
+ ///
+ ///
+ /// The size of the DeviceInterfaceDetailData buffer. The buffer must be at least ( offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA,
+ /// DevicePath) + sizeof(TCHAR)) bytes, to contain the fixed part of the structure and a single NULL to
+ /// terminate an empty MULTI_SZ string.
+ ///
+ /// This parameter must be zero if DeviceInterfaceDetailData is NULL.
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the required size of the DeviceInterfaceDetailData buffer. This size
+ /// includes the size of the fixed part of the structure plus the number of bytes required for the variable-length device path
+ /// string. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a buffer that receives information about the device that supports the requested interface. The caller must set
+ /// DeviceInfoData .cbSize to sizeof(SP_DEVINFO_DATA). This parameter is optional and can be NULL.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
+ /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// Using this function to get details about an interface is typically a two-step process:
+ ///
+ /// -
+ ///
+ /// Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULL DeviceInterfaceDetailData pointer,
+ /// a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize variable. In response to such a call, this function returns
+ /// the required buffer size at RequiredSize and fails with GetLastError returning ERROR_INSUFFICIENT_BUFFER.
+ ///
+ ///
+ /// -
+ /// Allocate an appropriately sized buffer and call the function again to get the interface details.
+ ///
+ ///
+ ///
+ /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as
+ /// CreateFile. Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceDetail can be used to get just the DeviceInfoData. If the interface exists but
+ /// DeviceInterfaceDetailData is NULL, this function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the
+ /// DeviceInfoData structure is filled with information about the device that exposes the interface.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
+ // PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [Out, Optional] IntPtr DeviceInterfaceDetailData, uint DeviceInterfaceDetailDataSize, out uint RequiredSize, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
+ ///
+ /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
+ /// returned by SetupDiGetClassDevs.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details.
+ /// A pointer of this type is typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure to receive information about the specified interface. This parameter
+ /// is optional and can be NULL. This parameter must be NULL if DeviceInterfaceDetailSize is zero. If this parameter
+ /// is specified, the caller must set DeviceInterfaceDetailData .cbSize to sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
+ /// before calling this function. The cbSize member always contains the size of the fixed part of the data structure, not a
+ /// size reflecting the variable-length string at the end.
+ ///
+ ///
+ ///
+ /// The size of the DeviceInterfaceDetailData buffer. The buffer must be at least ( offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA,
+ /// DevicePath) + sizeof(TCHAR)) bytes, to contain the fixed part of the structure and a single NULL to
+ /// terminate an empty MULTI_SZ string.
+ ///
+ /// This parameter must be zero if DeviceInterfaceDetailData is NULL.
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the required size of the DeviceInterfaceDetailData buffer. This size
+ /// includes the size of the fixed part of the structure plus the number of bytes required for the variable-length device path
+ /// string. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a buffer that receives information about the device that supports the requested interface. The caller must set
+ /// DeviceInfoData .cbSize to sizeof(SP_DEVINFO_DATA). This parameter is optional and can be NULL.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
+ /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// Using this function to get details about an interface is typically a two-step process:
+ ///
+ /// -
+ ///
+ /// Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULL DeviceInterfaceDetailData pointer,
+ /// a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize variable. In response to such a call, this function returns
+ /// the required buffer size at RequiredSize and fails with GetLastError returning ERROR_INSUFFICIENT_BUFFER.
+ ///
+ ///
+ /// -
+ /// Allocate an appropriately sized buffer and call the function again to get the interface details.
+ ///
+ ///
+ ///
+ /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as
+ /// CreateFile. Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceDetail can be used to get just the DeviceInfoData. If the interface exists but
+ /// DeviceInterfaceDetailData is NULL, this function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the
+ /// DeviceInfoData structure is filled with information about the device that exposes the interface.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
+ // PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [Out, Optional] IntPtr DeviceInterfaceDetailData, uint DeviceInterfaceDetailDataSize, out uint RequiredSize, IntPtr DeviceInfoData = default);
+
+ /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
+ ///
+ /// A pointer to the device information set that contains the interface for which to retrieve details. This handle is typically
+ /// returned by SetupDiGetClassDevs.
+ ///
+ ///
+ /// An SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to retrieve details. This value is
+ /// typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ ///
+ /// A string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile.
+ ///
+ /// Receives information about the device that supports the requested interface.
+ ///
+ /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
+ /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacedetaila WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfaceDetailA( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ // PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize,
+ // PSP_DEVINFO_DATA DeviceInfoData );
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfaceDetailA")]
+ public static bool SetupDiGetDeviceInterfaceDetail(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, out string DeviceInterfacePath, out SP_DEVINFO_DATA DeviceInfoData)
+ {
+ SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, default, 0, out var sz);
+ Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER);
+ using var mem = new SafeSP_DEVICE_INTERFACE_DETAIL_DATA(sz);
+ DeviceInfoData = new SP_DEVINFO_DATA { cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA)) };
+ var ret = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, mem, sz, out sz, ref DeviceInfoData);
+ DeviceInterfacePath = ret ? mem.DevicePath : null;
+ return ret;
+ }
+
+ /// The SetupDiGetDeviceInterfaceProperty function retrieves a device property that is set for a device interface.
+ ///
+ /// A handle to a device information set that contains a device interface for which to retrieve a device interface property.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that represents the device interface for which to retrieve a device interface property.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device interface property key of the device interface property to retrieve.
+ ///
+ ///
+ /// A pointer to a DEVPROPTYPE-typed variable that receives the property-data-type identifier of the requested device interface
+ /// property. The property-data-type identifier is a 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 interface property. SetupDiGetDeviceInterfaceProperty 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, SetupDiGetDeviceInterfaceProperty returns the size of
+ /// the property, in bytes, in *RequiredSize.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the size, in bytes, of either the device interface 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.
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the
+ /// logged error can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// The following table includes some of the more common error codes that this function might log. Other error codes can be set by
+ /// the device installer functions that are called by this API.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ ///
+ /// A supplied parameter is not valid. One possibility is that the device interface that is specified by DeviceInterfaceData is not valid.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified internal data value was not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVICE_INTERFACE
+ /// The device interface that is specified by DeviceInterfaceData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ ///
+ /// The PropertyBuffer buffer is not large enough to hold the property value, or an internal data buffer that was passed to a system
+ /// call was too small.
+ ///
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// The requested device property does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceInterfaceProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiGetDeviceInterfaceProperty.
+ ///
+ /// A caller of SetupDiGetDeviceInterfaceProperty must be a member of the Administrators group to set a device interface property.
+ ///
+ /// To obtain the device property keys that represent the device properties that are set for a device interface, call SetupDiGetDeviceInterfacePropertyKeys.
+ /// To set a device interface property, call SetupDiSetDeviceInterfaceProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacepropertyw WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfacePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, const DEVPROPKEY
+ // *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfacePropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInterfaceProperty(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize,
+ out uint RequiredSize, [In, Optional] uint Flags);
+
+ ///
+ /// The SetupDiGetDeviceInterfacePropertyKeys function retrieves an array of device property keys that represent the device
+ /// properties that are set for a device interface.
+ ///
+ ///
+ /// A handle to a device information set. This device information set contains a device interface for which to retrieve an array of
+ /// the device property keys that represent the device properties that are set for a device interface.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that represents the device interface for which to retrieve the requested
+ /// array of device property keys.
+ ///
+ ///
+ /// A pointer to a buffer that receives an array of DEVPROPKEY-typed values, where each value is a device property key for a device
+ /// property that is set for the device interface. The pointer is optional and can be NULL. For more information, see the
+ /// Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in DEVPROPKEY-typed elements, of the PropertyKeyArray buffer. If PropertyKeyArray is NULL, PropertyKeyCount
+ /// must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of requested device property keys. The pointer is optional and can
+ /// be set to NULL.
+ ///
+ /// This parameter must be set to zero.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error can be retrieved
+ /// by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An internal data value is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// A parameter is not valid. One possibility is that the device interface that is specified by DevInterfaceData is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyKeyArray is NULL, and PropertKeyCount is not zero. .
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVICE_INTERFACE
+ /// The device interface that is specified by DeviceInterfaceData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// The PropertyKeyArray buffer is not large enough to hold all the requested property keys.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceInterfacePropertyKeys is part of the unified device property model.
+ ///
+ /// If the PropertyKeyArray buffer is not large enough to hold all the requested property keys,
+ /// SetupDiGetDeviceInterfacePropertyKeys does not retrieve any property keys and returns ERROR_INSUFFICIENT_BUFFER. If the
+ /// caller supplied a RequiredPropertyKeyCount pointer, SetupDiGetDeviceInterfacePropertyKeys sets the value of
+ /// *RequiredPropertyKeyCount to the required size, in DEVPROPKEY-typed values, of the PropertyKeyArray buffer.
+ ///
+ ///
+ /// To retrieve a device interface property, call SetupDiGetDeviceInterfaceProperty , and to set a device interface property,
+ /// call SetupDiSetDeviceInterfaceProperty.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceinterfacepropertykeys WINSETUPAPI BOOL
+ // SetupDiGetDeviceInterfacePropertyKeys( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DEVPROPKEY
+ // *PropertyKeyArray, DWORD PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceInterfacePropertyKeys")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceInterfacePropertyKeys(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] DEVPROPKEY[] PropertyKeyArray, uint PropertyKeyCount,
+ out uint RequiredPropertyKeyCount, [In, Optional] uint Flags);
+
+ /// The SetupDiGetDeviceProperty function 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 SP_DEVINFO_DATA structure that represents the device instance for which to retrieve a device instance property.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
+ ///
+ ///
+ /// A pointer to a DEVPROPTYPE-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. SetupDiGetDeviceProperty 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, SetupDiGetDeviceProperty returns the size of the
+ /// property, in bytes, in *RequiredSize.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize 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.
+ ///
+ ///
+ /// SetupDiGetDeviceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified internal data value was not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL and PropertBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVINST
+ /// The device instance that is specified by DevInfoData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ ///
+ /// The PropertyBuffer buffer is too small to hold the requested property value, or an internal data buffer that was passed to a
+ /// system call was too small.
+ ///
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// The requested device property does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiGetDeviceProperty.
+ /// To obtain the device property keys that represent the device properties that are set for a device instance, call SetupDiGetDevicePropertyKeys.
+ /// To set a device instance property, call SetupDiSetDeviceProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdevicepropertyw WINSETUPAPI BOOL
+ // SetupDiGetDevicePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const DEVPROPKEY *PropertyKey, DEVPROPTYPE
+ // *PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in DEVPROPKEY PropertyKey,
+ out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize, uint Flags = 0);
+
+ /// The SetupDiGetDeviceProperty function 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 SP_DEVINFO_DATA structure that represents the device instance for which to retrieve a device instance property.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
+ ///
+ ///
+ /// A pointer to a buffer that receives the requested device instance property. SetupDiGetDeviceProperty 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, SetupDiGetDeviceProperty returns the size of the
+ /// property, in bytes, in *RequiredSize.
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An unspecified internal data value was not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL and PropertBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVINST
+ /// The device instance that is specified by DevInfoData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ ///
+ /// The PropertyBuffer buffer is too small to hold the requested property value, or an internal data buffer that was passed to a
+ /// system call was too small.
+ ///
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// The requested device property does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiGetDeviceProperty.
+ /// To obtain the device property keys that represent the device properties that are set for a device instance, call SetupDiGetDevicePropertyKeys.
+ /// To set a device instance property, call SetupDiSetDeviceProperty.
+ ///
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyW")]
+ public static bool SetupDiGetDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in DEVPROPKEY PropertyKey, out object Value)
+ {
+ Value = null;
+ if (!SetupDiGetDeviceProperty(DeviceInfoSet, DeviceInfoData, PropertyKey, out _, default, 0, out var sz) && Win32Error.GetLastError() != Win32Error.ERROR_INSUFFICIENT_BUFFER)
+ return false;
+ using var mem = new SafeCoTaskMemHandle(sz);
+ if (SetupDiGetDeviceProperty(DeviceInfoSet, DeviceInfoData, PropertyKey, out var propType, mem, mem.Size, out _))
+ {
+ switch (propType)
+ {
+ case DEVPROPTYPE.DEVPROP_TYPE_EMPTY:
+ case DEVPROPTYPE.DEVPROP_TYPE_NULL:
+ Value = null;
+ return true;
+
+ case DEVPROPTYPE.DEVPROP_TYPE_SECURITY_DESCRIPTOR:
+ Value = new RawSecurityDescriptor(mem.GetBytes(0, mem.Size), 0);
+ return true;
+
+ case DEVPROPTYPE.DEVPROP_TYPE_STRING_INDIRECT:
+ Value = mem.ToString(-1, CharSet.Unicode);
+ return true;
+
+ case DEVPROPTYPE.DEVPROP_TYPE_STRING_LIST:
+ Value = mem.ToStringEnum(CharSet.Unicode).ToArray();
+ return true;
+
+ default:
+ (DEVPROPTYPE type, DEVPROPTYPE mod) spt = propType.Split();
+ var type = CorrespondingTypeAttribute.GetCorrespondingTypes(spt.type).FirstOrDefault();
+ if (type is not null)
+ {
+ Value = spt.mod switch
+ {
+ 0 => mem.DangerousGetHandle().Convert(mem.Size, type, CharSet.Unicode),
+ DEVPROPTYPE.DEVPROP_TYPEMOD_ARRAY => mem.DangerousGetHandle().ToArray(type, mem.Size / Marshal.SizeOf(type), 0, mem.Size),
+ _ => null
+ };
+ if (Value is not null)
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// The SetupDiGetDevicePropertyKeys function retrieves an array of the device property keys that represent the device
+ /// properties that are set for a device instance.
+ ///
+ ///
+ /// A handle to a device information set. This device information set contains the device instance for which this function retrieves
+ /// an array of device property keys. The property keys represent the device properties that are set for the device instance.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that represents the device instance for which to retrieve the requested array of
+ /// device property keys.
+ ///
+ ///
+ /// A pointer to a buffer that receives an array of DEVPROPKEY-typed values, where each value is a device property key that
+ /// represents a device property that is set for the device instance. The pointer is optional and can be NULL. For more
+ /// information, see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in DEVPROPKEY-typed values, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL,
+ /// PropertyKeyCount must be set to zero.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of requested device property keys. The pointer is optional and can
+ /// be set to NULL.
+ ///
+ /// This parameter must be set to zero.
+ ///
+ ///
+ /// SetupDiGetDevicePropertyKeys returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ /// An internal data value is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyKeyArray is NULL and PropertKeyCount is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVINST
+ /// The device instance that is specified by DevInfoData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// The PropertyKeyArray buffer is too small to hold all the requested property keys.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiGetDevicePropertyKeys is part of the unified device property model.
+ ///
+ /// If the ProperKeyArray buffer is not large enough to hold all the requested property keys, SetupDiGetDevicePropertyKeys
+ /// does not retrieve any property keys and returns ERROR_INSUFFICIENT_BUFFER. If the caller supplied a RequiredPropertyKeyCount
+ /// pointer, SetupDiGetDevicePropertyKeys sets the value of *RequiredPropertyKeyCount to the required size, in
+ /// DEVPROPKEY-typed values, of the PropertyKeyArray buffer.
+ ///
+ /// To retrieve a device instance property, call SetupDiGetDeviceProperty, and to set a device instance property, call SetupDiSetDeviceProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdevicepropertykeys WINSETUPAPI BOOL
+ // SetupDiGetDevicePropertyKeys( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DEVPROPKEY *PropertyKeyArray, DWORD
+ // PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDevicePropertyKeys")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDevicePropertyKeys(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] DEVPROPKEY[] PropertyKeyArray, uint PropertyKeyCount,
+ out uint RequiredPropertyKeyCount, uint Flags = 0);
+
+ /// The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to retrieve
+ /// a Plug and Play property.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// One of the following values that specifies the property to be retrieved:
+ /// SPDRP_ADDRESS
+ /// The function retrieves the device's address.
+ /// SPDRP_BUSNUMBER
+ /// The function retrieves the device's bus number.
+ /// SPDRP_BUSTYPEGUID
+ /// The function retrieves the GUID for the device's bus type.
+ /// SPDRP_CAPABILITIES
+ ///
+ /// The function retrieves a bitwise OR of the following CM_DEVCAP_Xxx flags in a DWORD. The device capabilities that are
+ /// represented by these flags correspond to the device capabilities that are represented by the members of the DEVICE_CAPABILITIES
+ /// structure. The CM_DEVCAP_Xxx constants are defined in Cfgmgr32.h.
+ ///
+ ///
+ ///
+ /// CM_DEVCAP_Xxx flag
+ /// Corresponding DEVICE_CAPABILITIES structure member
+ ///
+ /// -
+ /// CM_DEVCAP_LOCKSUPPORTED
+ /// LockSupported
+ ///
+ /// -
+ /// CM_DEVCAP_EJECTSUPPORTED
+ /// EjectSupported
+ ///
+ /// -
+ /// CM_DEVCAP_REMOVABLE
+ /// Removable
+ ///
+ /// -
+ /// CM_DEVCAP_DOCKDEVICE
+ /// DockDevice
+ ///
+ /// -
+ /// CM_DEVCAP_UNIQUEID
+ /// UniqueID
+ ///
+ /// -
+ /// CM_DEVCAP_SILENTINSTALL
+ /// SilentInstall
+ ///
+ /// -
+ /// CM_DEVCAP_RAWDEVICEOK
+ /// RawDeviceOK
+ ///
+ /// -
+ /// CM_DEVCAP_SURPRISEREMOVALOK
+ /// SurpriseRemovalOK
+ ///
+ /// -
+ /// CM_DEVCAP_HARDWAREDISABLED
+ /// HardwareDisabled
+ ///
+ /// -
+ /// CM_DEVCAP_NONDYNAMIC
+ /// NonDynamic
+ ///
+ ///
+ /// SPDRP_CHARACTERISTICS
+ ///
+ /// The function retrieves a bitwise OR of a device's characteristics flags in a DWORD. For a description of these flags, which are
+ /// defined in Wdm.h and Ntddk.h, see the DeviceCharacteristics parameter of the IoCreateDevice function.
+ ///
+ /// SPDRP_CLASS
+ /// The function retrieves a REG_SZ string that contains the device setup class of a device.
+ /// SPDRP_CLASSGUID
+ /// The function retrieves a REG_SZ string that contains the GUID that represents the device setup class of a device.
+ /// SPDRP_COMPATIBLEIDS
+ ///
+ /// The function retrieves a REG_MULTI_SZ string that contains the list of compatible IDs for a device. For information about
+ /// compatible IDs, see Device Identification Strings.
+ ///
+ /// SPDRP_CONFIGFLAGS
+ ///
+ /// The function retrieves a bitwise OR of a device's configuration flags in a DWORD value. The configuration flags are represented
+ /// by the CONFIGFLAG_Xxx bitmasks that are defined in Regstr.h.
+ ///
+ /// SPDRP_DEVICE_POWER_DATA
+ /// (Windows XP and later) The function retrieves a CM_POWER_DATA structure that contains the device's power management information.
+ /// SPDRP_DEVICEDESC
+ /// The function retrieves a REG_SZ string that contains the description of a device.
+ /// SPDRP_DEVTYPE
+ /// The function retrieves a DWORD value that represents the device's type. For more information, see Specifying Device Types.
+ /// SPDRP_DRIVER
+ ///
+ /// The function retrieves a string that identifies the device's software key (sometimes called the driver key). For more
+ /// information about driver keys, see Registry Trees and Keys for Devices and Drivers.
+ ///
+ /// SPDRP_ENUMERATOR_NAME
+ /// The function retrieves a REG_SZ string that contains the name of the device's enumerator.
+ /// SPDRP_EXCLUSIVE
+ ///
+ /// The function retrieves a DWORD value that indicates whether a user can obtain exclusive use of the device. The returned value is
+ /// one if exclusive use is allowed, or zero otherwise. For more information, see IoCreateDevice.
+ ///
+ /// SPDRP_FRIENDLYNAME
+ /// The function retrieves a REG_SZ string that contains the friendly name of a device.
+ /// SPDRP_HARDWAREID
+ ///
+ /// The function retrieves a REG_MULTI_SZ string that contains the list of hardware IDs for a device. For information about hardware
+ /// IDs, see Device Identification Strings.
+ ///
+ /// SPDRP_INSTALL_STATE
+ ///
+ /// (Windows XP and later) The function retrieves a DWORD value that indicates the installation state of a device. The installation
+ /// state is represented by one of the CM_INSTALL_STATE_Xxx values that are defined in Cfgmgr32.h. The CM_INSTALL_STATE_Xxx values
+ /// correspond to the DEVICE_INSTALL_STATE enumeration values.
+ ///
+ /// SPDRP_LEGACYBUSTYPE
+ /// The function retrieves the device's legacy bus type as an INTERFACE_TYPE value (defined in Wdm.h and Ntddk.h).
+ /// SPDRP_LOCATION_INFORMATION
+ /// The function retrieves a REG_SZ string that contains the hardware location of a device.
+ /// SPDRP_LOCATION_PATHS
+ ///
+ /// (Windows Server 2003 and later) The function retrieves a REG_MULTI_SZ string that represents the location of the device in the
+ /// device tree.
+ ///
+ /// SPDRP_LOWERFILTERS
+ /// The function retrieves a REG_MULTI_SZ string that contains the names of a device's lower-filter drivers.
+ /// SPDRP_MFG
+ /// The function retrieves a REG_SZ string that contains the name of the device manufacturer.
+ /// SPDRP_PHYSICAL_DEVICE_OBJECT_NAME
+ ///
+ /// The function retrieves a REG_SZ string that contains the name that is associated with the device's PDO. For more information,
+ /// see IoCreateDevice.
+ ///
+ /// SPDRP_REMOVAL_POLICY
+ ///
+ /// (Windows XP and later) The function retrieves the device's current removal policy as a DWORD that contains one of the
+ /// CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ /// SPDRP_REMOVAL_POLICY_HW_DEFAULT
+ ///
+ /// (Windows XP and later) The function retrieves the device's hardware-specified default removal policy as a DWORD that contains
+ /// one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ /// SPDRP_REMOVAL_POLICY_OVERRIDE
+ ///
+ /// (Windows XP and later) The function retrieves the device's override removal policy (if it exists) from the registry, as a DWORD
+ /// that contains one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ /// SPDRP_SECURITY
+ /// The function retrieves a SECURITY_DESCRIPTOR structure for a device.
+ /// SPDRP_SECURITY_SDS
+ ///
+ /// The function retrieves a REG_SZ string that contains the device's security descriptor. For information about security descriptor
+ /// strings, see Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings,
+ /// see Security Descriptor Definition Language (Windows).
+ ///
+ /// SPDRP_SERVICE
+ /// The function retrieves a REG_SZ string that contains the service name for a device.
+ /// SPDRP_UI_NUMBER
+ ///
+ /// The function retrieves a DWORD value set to the value of the UINumber member of the device's DEVICE_CAPABILITIES structure.
+ ///
+ /// SPDRP_UI_NUMBER_DESC_FORMAT
+ /// The function retrieves a format string (REG_SZ) used to display the UINumber value.
+ /// SPDRP_UPPERFILTERS
+ /// The function retrieves a REG_MULTI_SZ string that contains the names of a device's upper filter drivers.
+ ///
+ ///
+ /// A pointer to a variable that receives the data type of the property that is being retrieved. This is one of the standard
+ /// registry data types. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a buffer that receives the property that is being retrieved. If this parameter is set to NULL, and
+ /// PropertyBufferSize is also set to zero, the function returns the required size for the buffer in RequiredSize.
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer that is required
+ /// to hold the data for the requested property. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and
+ /// the logged error can be retrieved by making a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the
+ /// ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdeviceregistrypropertya WINSETUPAPI BOOL
+ // SetupDiGetDeviceRegistryPropertyA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD
+ // PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceRegistryPropertyA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDeviceRegistryProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, SPDRP Property,
+ out REG_VALUE_TYPE PropertyRegDataType, [Out, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetDriverInfoDetail function retrieves driver information detail for a device information set or a particular
+ /// device information element in the device information set.
+ ///
+ ///
+ /// A handle to a device information set that contains a driver information element for which to retrieve driver information.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element that represents the device for which to
+ /// retrieve driver information. This parameter is optional and can be NULL. If this parameter is specified,
+ /// SetupDiGetDriverInfoDetail retrieves information about a driver in a driver list for the specified device. If this
+ /// parameter is NULL, SetupDiGetDriverInfoDetail retrieves information about a driver that is a member of the global
+ /// class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver information element that represents the driver for which to
+ /// retrieve details. If DeviceInfoData is specified, the driver must be a member of the driver list for the device that is
+ /// specified by DeviceInfoData. Otherwise, the driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DETAIL_DATA structure that receives detailed information about the specified driver. If this
+ /// parameter is not specified, DriverInfoDetailDataSize must be zero. If this parameter is specified, DriverInfoDetailData.
+ /// cbSize must be set to the value of sizeof( SP_DRVINFO_DETAIL_DATA ) before it calls SetupDiGetDriverInfoDetail.
+ ///
+ /// Note DriverInfoDetailData. cbSize must not be set to the value of the DriverInfoDetailDataSize parameter.
+ ///
+ /// The size, in bytes, of the DriverInfoDetailData buffer.
+ ///
+ /// A pointer to a variable that receives the number of bytes required to store the detailed driver information. This value includes
+ /// both the size of the structure and the additional bytes required for the variable-length character buffer at the end that holds
+ /// the hardware ID list and the compatible ID list. The lists are in REG_MULTI_SZ format. For information about hardware and
+ /// compatible IDs, see Device Identification Strings.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// If the specified driver information member and the caller-supplied buffer are both valid, this function is guaranteed to fill in
+ /// all static fields in the SP_DRVINFO_DETAIL_DATA structure and as many IDs as possible in the variable-length buffer at the end
+ /// while still maintaining REG_MULTI_SZ format. In this case, the function returns FALSE and a call to GetLastError returns
+ /// ERROR_INSUFFICIENT_BUFFER. If specified, RequiredSize contains the total number of bytes required for the structure with all IDs.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdriverinfodetaila WINSETUPAPI BOOL
+ // SetupDiGetDriverInfoDetailA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINFO_DETAIL_DATA_A DriverInfoDetailData, DWORD DriverInfoDetailDataSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDriverInfoDetailA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDriverInfoDetail(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, in SP_DRVINFO_DATA_V2 DriverInfoData,
+ ref SP_DRVINFO_DETAIL_DATA DriverInfoDetailData, uint DriverInfoDetailDataSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetDriverInfoDetail function retrieves driver information detail for a device information set or a particular
+ /// device information element in the device information set.
+ ///
+ ///
+ /// A handle to a device information set that contains a driver information element for which to retrieve driver information.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element that represents the device for which to
+ /// retrieve driver information. This parameter is optional and can be NULL. If this parameter is specified,
+ /// SetupDiGetDriverInfoDetail retrieves information about a driver in a driver list for the specified device. If this
+ /// parameter is NULL, SetupDiGetDriverInfoDetail retrieves information about a driver that is a member of the global
+ /// class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver information element that represents the driver for which to
+ /// retrieve details. If DeviceInfoData is specified, the driver must be a member of the driver list for the device that is
+ /// specified by DeviceInfoData. Otherwise, the driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DETAIL_DATA structure that receives detailed information about the specified driver. If this
+ /// parameter is not specified, DriverInfoDetailDataSize must be zero. If this parameter is specified, DriverInfoDetailData.
+ /// cbSize must be set to the value of sizeof( SP_DRVINFO_DETAIL_DATA ) before it calls SetupDiGetDriverInfoDetail.
+ ///
+ /// Note DriverInfoDetailData. cbSize must not be set to the value of the DriverInfoDetailDataSize parameter.
+ ///
+ /// The size, in bytes, of the DriverInfoDetailData buffer.
+ ///
+ /// A pointer to a variable that receives the number of bytes required to store the detailed driver information. This value includes
+ /// both the size of the structure and the additional bytes required for the variable-length character buffer at the end that holds
+ /// the hardware ID list and the compatible ID list. The lists are in REG_MULTI_SZ format. For information about hardware and
+ /// compatible IDs, see Device Identification Strings.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ /// If the specified driver information member and the caller-supplied buffer are both valid, this function is guaranteed to fill in
+ /// all static fields in the SP_DRVINFO_DETAIL_DATA structure and as many IDs as possible in the variable-length buffer at the end
+ /// while still maintaining REG_MULTI_SZ format. In this case, the function returns FALSE and a call to GetLastError returns
+ /// ERROR_INSUFFICIENT_BUFFER. If specified, RequiredSize contains the total number of bytes required for the structure with all IDs.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdriverinfodetaila WINSETUPAPI BOOL
+ // SetupDiGetDriverInfoDetailA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINFO_DETAIL_DATA_A DriverInfoDetailData, DWORD DriverInfoDetailDataSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDriverInfoDetailA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDriverInfoDetail(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, in SP_DRVINFO_DATA_V2 DriverInfoData,
+ ref SP_DRVINFO_DETAIL_DATA DriverInfoDetailData, uint DriverInfoDetailDataSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetDriverInstallParams function retrieves driver installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ ///
+ /// A handle to a device information set that contains a driver information element that represents the driver for which to retrieve
+ /// installation parameters.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that contains a device information element that represents the device for which to
+ /// retrieve installation parameters. This parameter is optional and can be NULL. If this parameter is specified,
+ /// SetupDiGetDriverInstallParams retrieves information about a driver that is a member of a driver list for the specified
+ /// device. If this parameter is NULL, SetupDiGetDriverInstallParams retrieves information about a driver that is a
+ /// member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver information element that represents the driver for which to
+ /// retrieve installation parameters. If DeviceInfoData is supplied, the driver must be a member of the driver list for the device
+ /// that is specified by DeviceInfoData. Otherwise, the driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINSTALL_PARAMS structure to receive the installation parameters for this driver.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdriverinstallparamsa WINSETUPAPI BOOL
+ // SetupDiGetDriverInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINSTALL_PARAMS DriverInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDriverInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDriverInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ in SP_DRVINFO_DATA_V2 DriverInfoData, ref SP_DRVINSTALL_PARAMS DriverInstallParams);
+
+ ///
+ /// The SetupDiGetDriverInstallParams function retrieves driver installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ ///
+ /// A handle to a device information set that contains a driver information element that represents the driver for which to retrieve
+ /// installation parameters.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that contains a device information element that represents the device for which to
+ /// retrieve installation parameters. This parameter is optional and can be NULL. If this parameter is specified,
+ /// SetupDiGetDriverInstallParams retrieves information about a driver that is a member of a driver list for the specified
+ /// device. If this parameter is NULL, SetupDiGetDriverInstallParams retrieves information about a driver that is a
+ /// member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver information element that represents the driver for which to
+ /// retrieve installation parameters. If DeviceInfoData is supplied, the driver must be a member of the driver list for the device
+ /// that is specified by DeviceInfoData. Otherwise, the driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINSTALL_PARAMS structure to receive the installation parameters for this driver.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetdriverinstallparamsa WINSETUPAPI BOOL
+ // SetupDiGetDriverInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINSTALL_PARAMS DriverInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDriverInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetDriverInstallParams(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData,
+ in SP_DRVINFO_DATA_V2 DriverInfoData, ref SP_DRVINSTALL_PARAMS DriverInstallParams);
+
+ ///
+ /// The SetupDiGetHwProfileFriendlyName function retrieves the friendly name associated with a hardware profile ID.
+ ///
+ ///
+ /// The hardware profile ID associated with the friendly name to retrieve. If this parameter is 0, the friendly name for the current
+ /// hardware profile is retrieved.
+ ///
+ /// A pointer to a string buffer to receive the friendly name.
+ /// The size, in characters, of the FriendlyName buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the number of characters required to retrieve the friendly name (including a
+ /// NULL terminator).
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ /// Call SetupDiGetHwProfileFriendlyNameEx to get the friendly name of a hardware profile ID on a remote computer.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigethwprofilefriendlynamea WINSETUPAPI BOOL
+ // SetupDiGetHwProfileFriendlyNameA( DWORD HwProfile, PSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetHwProfileFriendlyNameA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetHwProfileFriendlyName(uint HwProfile, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder FriendlyName,
+ uint FriendlyNameSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetHwProfileFriendlyNameEx function retrieves the friendly name associated with a hardware profile ID on a
+ /// local or remote computer.
+ ///
+ ///
+ /// Supplies the hardware profile ID associated with the friendly name to retrieve. If this parameter is 0, the friendly name for
+ /// the current hardware profile is retrieved.
+ ///
+ /// A pointer to a character buffer to receive the friendly name.
+ /// The size, in characters, of the FriendlyName buffer.
+ ///
+ /// A pointer to a variable to receive the number of characters required to store the friendly name (including a NULL terminator).
+ /// This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to NULL-terminated string that contains the name of a remote computer on which the hardware profile ID resides. This
+ /// parameter is optional and can be NULL. If MachineName is NULL, the hardware profile ID is on the local computer.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigethwprofilefriendlynameexa WINSETUPAPI BOOL
+ // SetupDiGetHwProfileFriendlyNameExA( DWORD HwProfile, PSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize, PCSTR
+ // MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetHwProfileFriendlyNameExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetHwProfileFriendlyNameEx(uint HwProfile, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder FriendlyName,
+ uint FriendlyNameSize, out uint RequiredSize, [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiGetHwProfileList function retrieves a list of all currently defined hardware profile IDs.
+ /// A pointer to an array to receive the list of currently defined hardware profile IDs.
+ /// The number of DWORDs in the HwProfileList buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the number of hardware profiles currently defined. If the number is larger
+ /// than HwProfileListSize, the list is truncated to fit the array size. The value returned in RequiredSize indicates the array size
+ /// required to store the entire list of hardware profiles. In this case, the function fails and a call to GetLastError returns ERROR_INSUFFICIENT_BUFFER.
+ ///
+ ///
+ /// A pointer to a variable of type DWORD that receives the index of the currently active hardware profile in the retrieved hardware
+ /// profile list. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError.
+ ///
+ /// Call SetupDiGetHwProfileListEx to retrieve the hardware profile IDs for a remote computer.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigethwprofilelist WINSETUPAPI BOOL
+ // SetupDiGetHwProfileList( PDWORD HwProfileList, DWORD HwProfileListSize, PDWORD RequiredSize, PDWORD CurrentlyActiveIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetHwProfileList")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetHwProfileList([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] HwProfileList,
+ uint HwProfileListSize, out uint RequiredSize, out uint CurrentlyActiveIndex);
+
+ ///
+ /// The SetupDiGetHwProfileListEx function retrieves a list of all currently defined hardware profile IDs on a local or
+ /// remote computer.
+ ///
+ /// A pointer to an array to receive the list of currently defined hardware profile IDs.
+ /// The number of DWORDs in the HwProfileList buffer.
+ ///
+ /// A pointer to a variable of type DWORD that receives the number of hardware profiles that are currently defined. If the number is
+ /// larger than HwProfileListSize, the list is truncated to fit the array size. The value returned in RequiredSize indicates the
+ /// array size required to store the entire list of hardware profiles.
+ ///
+ ///
+ /// A pointer to a variable that receives the index of the currently active hardware profile in the retrieved hardware profile list.
+ /// This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote system for which to retrieve the list of hardware
+ /// profile IDs. This parameter is optional and can be NULL. If this parameter is NULL, the list is retrieved for the
+ /// local system.
+ ///
+ /// Must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by making a call to GetLastError. If the required size is larger than HwProfileListSize, SetupDiGetHwProfileListEx
+ /// returns FALSE and a call to GetLastError returns ERROR_INSUFFICIENT_BUFFER.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigethwprofilelistexa WINSETUPAPI BOOL
+ // SetupDiGetHwProfileListExA( PDWORD HwProfileList, DWORD HwProfileListSize, PDWORD RequiredSize, PDWORD CurrentlyActiveIndex,
+ // PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetHwProfileListExA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetHwProfileListEx([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] HwProfileList,
+ uint HwProfileListSize, out uint RequiredSize, out uint CurrentlyActiveIndex,
+ [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiGetINFClass function returns the class of a specified device INF file.
+ ///
+ /// A pointer to a NULL-terminated string that supplies the name of a device INF file. This name can include a path. However, if
+ /// just the file name is specified, the file is searched for in each directory that is listed in the DevicePath entry under
+ /// the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion subkey of the registry. The maximum length in characters, including a
+ /// NULL terminator, of a NULL-terminated INF file name is MAX_PATH.
+ ///
+ ///
+ /// A pointer to a variable of type GUID that receives the class GUID for the specified INF file. If the INF file does not specify a
+ /// class name, the function returns a GUID_NULL structure. Call SetupDiClassGuidsFromName to determine whether one or more classes
+ /// with this name are already installed.
+ ///
+ ///
+ /// A pointer to a buffer that receives a NULL-terminated string that contains the name of the class for the specified INF file. If
+ /// the INF file does not specify a class name but does specify a GUID, this buffer receives the name that is retrieved by calling
+ /// SetupDiClassNameFromGuid. However, if SetupDiClassNameFromGuid cannot retrieve a class name (for example, the class is
+ /// not installed), it returns an empty string.
+ ///
+ ///
+ /// The size, in characters, of the buffer that is pointed to by the ClassName parameter. The maximum length of a NULL-terminated
+ /// class name, in characters, is MAX_CLASS_NAME_LEN.
+ ///
+ ///
+ /// A pointer to a DWORD-typed variable that receives the number of characters that are required to store the class name, including
+ /// a terminating NULL. This pointer is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ /// Do not use this function with INF files for Windows 9x or Millennium Edition.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetinfclassw WINSETUPAPI BOOL SetupDiGetINFClassW(
+ // PCWSTR InfName, LPGUID ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetINFClassW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetINFClass([MarshalAs(UnmanagedType.LPTStr)] string InfName, out Guid ClassGuid,
+ [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ClassName, uint ClassNameSize, out uint RequiredSize);
+
+ ///
+ /// The SetupDiGetSelectedDevice function retrieves the selected device information element in a device information set.
+ ///
+ /// A handle to the device information set for which to retrieve the selected device information element.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that receives information about the selected device information element for
+ /// DeviceInfoSet. The caller must set DeviceInfoData. cbSize to sizeof(SP_DEVINFO_DATA). If a device is currently not
+ /// selected, the function fails and a call to GetLastError returns ERROR_NO_DEVICE_SELECTED.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ /// SetupDiGetSelectedDevice is usually used by an installation wizard.
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetselecteddevice WINSETUPAPI BOOL
+ // SetupDiGetSelectedDevice( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetSelectedDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetSelectedDevice(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiGetSelectedDriver function retrieves the selected driver for a device information set or a particular device
+ /// information element.
+ ///
+ /// A handle to the device information set for which to retrieve a selected driver.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element that represents the device in
+ /// DeviceInfoSet for which to retrieve the selected driver. This parameter is optional and can be NULL. If this parameter is
+ /// specified, SetupDiGetSelectedDriver retrieves the selected driver for the specified device. If this parameter is
+ /// NULL, SetupDiGetSelectedDriver retrieves the selected class driver in the global class driver list that is
+ /// associated with DeviceInfoSet.
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that receives information about the selected driver.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError. If a driver has not been selected for the specified device instance, the logged error is ERROR_NO_DRIVER_SELECTED.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetselecteddriverw WINSETUPAPI BOOL
+ // SetupDiGetSelectedDriverW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetSelectedDriverW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetSelectedDriver(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, ref SP_DRVINFO_DATA_V2 DriverInfoData);
+
+ ///
+ /// The SetupDiGetSelectedDriver function retrieves the selected driver for a device information set or a particular device
+ /// information element.
+ ///
+ /// A handle to the device information set for which to retrieve a selected driver.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element that represents the device in
+ /// DeviceInfoSet for which to retrieve the selected driver. This parameter is optional and can be NULL. If this parameter is
+ /// specified, SetupDiGetSelectedDriver retrieves the selected driver for the specified device. If this parameter is
+ /// NULL, SetupDiGetSelectedDriver retrieves the selected class driver in the global class driver list that is
+ /// associated with DeviceInfoSet.
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that receives information about the selected driver.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError. If a driver has not been selected for the specified device instance, the logged error is ERROR_NO_DRIVER_SELECTED.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdigetselecteddriverw WINSETUPAPI BOOL
+ // SetupDiGetSelectedDriverW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetSelectedDriverW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiGetSelectedDriver(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, ref SP_DRVINFO_DATA_V2 DriverInfoData);
+
+ /// The SetupDiInstallClass function installs the ClassInstall32 section of the specified INF file.
+ ///
+ /// The handle to the parent window for any user interface that is used to install this class. This parameter is optional and can be NULL.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of the INF file that contains an INF ClassInstall32 section.
+ ///
+ ///
+ /// These flags control the installation process. Can be a combination of the following:
+ /// DI_NOVCP
+ ///
+ /// Set this flag if FileQueue is supplied. DI_NOVCP instructs the SetupInstallFromInfSection function (described in
+ /// Microsoft Windows SDK documentation) not to create a queue of its own and to use the caller-supplied queue instead. If this flag
+ /// is set, files are not copied just queued.
+ ///
+ /// DI_NOBROWSE
+ ///
+ /// Set this flag to disable browsing if a copy operation cannot find a specified file. If the caller supplies a file queue, this
+ /// flag is ignored.
+ ///
+ /// DI_FORCECOPY
+ ///
+ /// Set this flag to always copy files, even if they are already present on the user's computer. If the caller supplies a file
+ /// queue, this flag is ignored.
+ ///
+ /// DI_QUIETINSTALL
+ ///
+ /// Set this flag to suppress the user interface unless absolutely necessary. For example, do not display the progress dialog. If
+ /// the caller supplies a file queue, this flag is ignored.
+ ///
+ ///
+ ///
+ /// If the DI_NOVCP flag is set, this parameter supplies a handle to a file queue where file operations should be queued but not committed.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ /// This function is called by a class installer when it installs a device of a new device class.
+ /// To install an interface class or a device class, use SetupDiInstallClassEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstallclassa WINSETUPAPI BOOL
+ // SetupDiInstallClassA( HWND hwndParent, PCSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallClassA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallClass([In, Optional] HWND hwndParent, [MarshalAs(UnmanagedType.LPTStr)] string InfFileName,
+ DI_FLAGS Flags, [In, Optional] HSPFILEQ FileQueue);
+
+ /// The SetupDiInstallClassEx function installs a class installer or an interface class.
+ ///
+ /// The handle to the parent window for any user interface that is used to install this class. This parameter is optional and can be NULL.
+ ///
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of an INF file. This parameter is optional and can be NULL.
+ /// If this function is being used to install a class installer, the INF file contains an INF ClassInstall32 section and this
+ /// parameter must not be NULL.
+ ///
+ /// If this function is being used to install an interface class, the INF file contains an INF InterfaceInstall32 section.
+ ///
+ ///
+ /// A value of type DWORD that controls the installation process. Flags can be zero or a bitwise OR of the following values:
+ /// DI_NOVCP
+ /// Set this flag if FileQueue is supplied.
+ ///
+ /// DI_NOVCP instructs the SetupInstallFromInfSection function not to create a queue of its own and to use the
+ /// caller-supplied queue instead.
+ ///
+ /// If this flag is set, files are not copied just queued.
+ /// For more information about the SetupInstallFromInfSection function, see the Microsoft Windows SDK documentation.
+ /// DI_NOBROWSE
+ ///
+ /// Set this flag to disable browsing if a copy operation cannot find a specified file. If the caller supplies a file queue, this
+ /// flag is ignored.
+ ///
+ /// DI_FORCECOPY
+ ///
+ /// Set this flag to always copy files, even if they are already present on the user's computer. If the caller supplies a file
+ /// queue, this flag is ignored.
+ ///
+ /// DI_QUIETINSTALL
+ ///
+ /// Set this flag to suppress the user interface unless absolutely necessary. For example, do not display the progress dialog. If
+ /// the caller supplies a file queue, this flag is ignored.
+ ///
+ ///
+ ///
+ /// If the DI_NOVCP flag is set, this parameter supplies a handle to a file queue where file operations should be queued but not committed.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the interface class to be installed. This parameter is optional and can be NULL. If
+ /// this parameter is specified, this function is being used to install the interface class represented by the GUID. If this
+ /// parameter is NULL, this function is being used to install a class installer.
+ ///
+ /// Reserved. Must be zero.
+ /// Reserved. Must be zero.
+ ///
+ /// SetupDiInstallClassEx returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error
+ /// can be retrieved with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiInstallClassEx is typically called by a class installer to install a new device setup class or a new device
+ /// interface class.
+ ///
+ ///
+ /// Note An interface class can also be installed automatically by calling SetupDiInstallDeviceInterfaces to install the
+ /// device interfaces for a device.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstallclassexw WINSETUPAPI BOOL
+ // SetupDiInstallClassExW( HWND hwndParent, PCWSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue, const GUID *InterfaceClassGuid,
+ // PVOID Reserved1, PVOID Reserved2 );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallClassExW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallClassEx([In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string InfFileName,
+ DI_FLAGS Flags, [In, Optional] HSPFILEQ FileQueue, in Guid InterfaceClassGuid, [In, Optional] IntPtr Reserved1, [In, Optional] IntPtr Reserved2);
+
+ /// The SetupDiInstallClassEx function installs a class installer or an interface class.
+ ///
+ /// The handle to the parent window for any user interface that is used to install this class. This parameter is optional and can be NULL.
+ ///
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of an INF file. This parameter is optional and can be NULL.
+ /// If this function is being used to install a class installer, the INF file contains an INF ClassInstall32 section and this
+ /// parameter must not be NULL.
+ ///
+ /// If this function is being used to install an interface class, the INF file contains an INF InterfaceInstall32 section.
+ ///
+ ///
+ /// A value of type DWORD that controls the installation process. Flags can be zero or a bitwise OR of the following values:
+ /// DI_NOVCP
+ /// Set this flag if FileQueue is supplied.
+ ///
+ /// DI_NOVCP instructs the SetupInstallFromInfSection function not to create a queue of its own and to use the
+ /// caller-supplied queue instead.
+ ///
+ /// If this flag is set, files are not copied just queued.
+ /// For more information about the SetupInstallFromInfSection function, see the Microsoft Windows SDK documentation.
+ /// DI_NOBROWSE
+ ///
+ /// Set this flag to disable browsing if a copy operation cannot find a specified file. If the caller supplies a file queue, this
+ /// flag is ignored.
+ ///
+ /// DI_FORCECOPY
+ ///
+ /// Set this flag to always copy files, even if they are already present on the user's computer. If the caller supplies a file
+ /// queue, this flag is ignored.
+ ///
+ /// DI_QUIETINSTALL
+ ///
+ /// Set this flag to suppress the user interface unless absolutely necessary. For example, do not display the progress dialog. If
+ /// the caller supplies a file queue, this flag is ignored.
+ ///
+ ///
+ ///
+ /// If the DI_NOVCP flag is set, this parameter supplies a handle to a file queue where file operations should be queued but not committed.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the interface class to be installed. This parameter is optional and can be NULL. If
+ /// this parameter is specified, this function is being used to install the interface class represented by the GUID. If this
+ /// parameter is NULL, this function is being used to install a class installer.
+ ///
+ /// Reserved. Must be zero.
+ /// Reserved. Must be zero.
+ ///
+ /// SetupDiInstallClassEx returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error
+ /// can be retrieved with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiInstallClassEx is typically called by a class installer to install a new device setup class or a new device
+ /// interface class.
+ ///
+ ///
+ /// Note An interface class can also be installed automatically by calling SetupDiInstallDeviceInterfaces to install the
+ /// device interfaces for a device.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstallclassexw WINSETUPAPI BOOL
+ // SetupDiInstallClassExW( HWND hwndParent, PCWSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue, const GUID *InterfaceClassGuid,
+ // PVOID Reserved1, PVOID Reserved2 );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallClassExW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallClassEx([In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string InfFileName,
+ DI_FLAGS Flags, [In, Optional] HSPFILEQ FileQueue, [In, Optional] IntPtr InterfaceClassGuid, [In, Optional] IntPtr Reserved1,
+ [In, Optional] IntPtr Reserved2);
+
+ /// The SetupDiInstallDevice function is the default handler for the DIF_INSTALLDEVICE installation request.
+ ///
+ /// A handle to the device information set for the local system that contains a device information element that represents the
+ /// device to install.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoData. DevInst might be updated with a new handle value upon return.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiInstallDevice installs a driver from the INF file. SetupAPI's definition of the "driver" is really a "driver
+ /// node." Therefore, when this function installs a driver, it also installs the items in the following list:
+ ///
+ ///
+ /// -
+ /// The service(s) for the device.
+ ///
+ /// -
+ /// The driver files.
+ ///
+ /// -
+ /// Device-specific co-installers (if any).
+ ///
+ /// -
+ /// Property-page providers (if any).
+ ///
+ /// -
+ /// Control-panel applets (if any).
+ ///
+ ///
+ /// This function also registers any required device interfaces.
+ /// A successful installation includes, but is not limited to, the following steps:
+ ///
+ /// -
+ /// Create a driver key in the registry and write appropriate entries (such as InfPath and ProviderName).
+ ///
+ /// -
+ ///
+ /// Locate and process the INF DDInstall section for the device. The section might be OS/architecture-specific. The DDInstall
+ /// section's AddReg and DelReg entries are directed at the device's software key. Locate and process the DDInstall
+ /// .HW section whose AddReg and DelReg entries are directed at the device's hardware key. Locate and process
+ /// the INF DDInstall.LogConfigOverride section, if present, to supply an override configuration for the device. Locate and process
+ /// the INF DDInstall.Services section to add services for the device (and potentially remove any old services that are no longer necessary).
+ ///
+ ///
+ /// -
+ /// Copy the INF file to the system INF directory.
+ ///
+ /// -
+ /// Possibly perform the other file operations, based on flag settings in the device installation parameters.
+ ///
+ /// -
+ /// Load the drivers for the device. This includes the function driver and any upper or lower-filter drivers.
+ ///
+ /// -
+ /// Call the drivers' AddDevice routines.
+ ///
+ /// -
+ /// Start the device by sending an IRP_MN_START_DEVICE I/O request packet (IRP).
+ ///
+ ///
+ ///
+ /// Windows does not start the device if the DI_NEEDRESTART, DI_NEEDREBOOT, or DI_DONOTCALLCONFIGMG flag is set in the
+ /// SP_DEVINSTALL_PARAMS structure.
+ ///
+ ///
+ /// A class installer should return ERROR_DI_DO_DEFAULT or call this function when handling a DIF_INSTALLDEVICE request. This
+ /// function performs many tasks for device installation and that list of tasks might be expanded in future releases. If a class
+ /// installer performs device installation without calling this function, the class installer might not work correctly on future
+ /// versions of the operating system.
+ ///
+ ///
+ /// If Windows cannot locate an INF file for the device, it will send DIF_INSTALLDEVICE in an attempt to install a null driver.
+ /// SetupDiInstallDevice installs a null driver only if the device supports raw mode or is a non-PnP device (reported by
+ /// IoReportDetectedDevice). For more information, see DIF_INSTALLDEVICE.
+ ///
+ ///
+ /// If the DI_FLAGSEX_SETFAILEDINSTALL flag is set in the SP_DEVINSTALL_PARAMS structure, SetupDiInstallDevice just sets the
+ /// FAILEDINSTALL flag in the device's ConfigFlags registry value.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiInstallDevice and only in those situations where the class
+ /// installer must perform device installation operations after SetupDiInstallDevice completes the default device
+ /// installation operation. In such situations, the class installer must directly call SetupDiInstallDevice when the
+ /// installer processes a DIF_INSTALLDEVICE request. For more information about calling the default handler, see Calling Default DIF
+ /// Code Handlers.
+ ///
+ /// The caller of SetupDiInstallDevice must be a member of the Administrators group.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstalldevice WINSETUPAPI BOOL
+ // SetupDiInstallDevice( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallDevice(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiInstallDeviceInterfaces function is the default handler for the DIF_INSTALLINTERFACES installation request.
+ ///
+ ///
+ /// A pointer to the device information set that contains a device information element that represents the device for which to
+ /// install interfaces. The device information set must contain only elements for the local system.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// SetupDiInstallDeviceInterfaces returns TRUE if the function completed without error. If the function completed
+ /// with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiInstallDeviceInterfaces processes each AddInterface entry in the DDInstall. Interfaces section of a
+ /// device INF file and creates each interface by calling SetupDiCreateDeviceInterface.
+ ///
+ /// The caller of SetupDiInstallDeviceInterfaces must be a member of the Administrators group.
+ ///
+ /// Note Only a class installer should call SetupDiInstallDeviceInterfaces and only in those situations where the
+ /// class installer must perform device interface installation operations after SetupDiInstallDeviceInterfaces completes the
+ /// default device interface installation operation. In such situations, the class installer must directly call
+ /// SetupDiInstallDeviceInterfaces when the installer processes a DIF_INSTALLINTERFACES request. For more information about
+ /// calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ /// For information about INF file format, see INF File Sections and Directives.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstalldeviceinterfaces WINSETUPAPI BOOL
+ // SetupDiInstallDeviceInterfaces( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallDeviceInterfaces")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallDeviceInterfaces(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiInstallDriverFiles function is the default handler for the DIF_INSTALLDEVICEFILES installation request.
+ ///
+ ///
+ /// A handle to the device information set that contains the device information element that represents the device for which to
+ /// install files. The device information set must not contain remote elements.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// The caller of SetupDiInstallDriverFiles must be a member of the Administrators group if this function is being used to
+ /// install files. However, if this function is being used to build up a file queue, membership in the Administrators group is not required.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiInstallDriverFiles and only in those situations where the class
+ /// installer must perform driver file installation operations after SetupDiInstallDriverFiles completes the default driver
+ /// file installation operation. In such situations, the class installer must directly call SetupDiInstallDriverFiles when
+ /// the installer processes a DIF_INSTALLDEVICEFILES request. For more information about calling the default handler, see Calling
+ /// Default DIF Code Handlers.
+ ///
+ ///
+ /// The operation of SetupDiInstallDriverFiles is similar to the SetupDiInstallDevice function. However, this function
+ /// performs only the file copy operations that are performed by SetupDiInstallDevice.
+ ///
+ /// A driver must be selected for the specified device information set or element before this function is called.
+ /// This function processes the CopyFiles, Delfiles, and Renfiles entries in the selected INF file.
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiinstalldriverfiles WINSETUPAPI BOOL
+ // SetupDiInstallDriverFiles( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiInstallDriverFiles")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiInstallDriverFiles(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiLoadClassIcon function loads both the large and mini-icon for the specified class.
+ /// A pointer to the GUID of the class for which the icon(s) should be loaded.
+ ///
+ /// A pointer to an icon handle that receives the handle value for the loaded large icon for the specified class. This pointer is
+ /// optional and can be NULL. If the pointer is NULL, the large icon is not loaded.
+ ///
+ ///
+ /// A pointer to an INT-typed variable that receives the index of the mini-icon for the specified class. The mini-icon is stored in
+ /// the device installer's mini-icon cache. The pointer is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// The icons of the class are either predefined and loaded from the device installer's internal cache, or they are loaded directly
+ /// from the class installer's executable. This function queries the registry value ICON in the specified class's section. If
+ /// the ICON value is specified, it indicates which mini-icon to load.
+ ///
+ ///
+ /// If the ICON value is negative, the absolute value represents a predefined icon in the class's registry. See
+ /// SetupDiDrawMiniIcon for a list of the predefined mini-icons.
+ ///
+ ///
+ /// If the ICON value is positive, it represents an icon in the class installer's executable image that will be extracted.
+ /// The value 1 is reserved. This function also uses the INSTALLER32 registry value and then the ENUMPROPPAGES32
+ /// registry value to determine which executable image to extract the icons from. For more information about these registry values,
+ /// see INF ClassInstall32 Section.
+ ///
+ ///
+ /// When a caller is finished using the icon, the caller must call DestroyIcon (which is described in the Microsoft Windows
+ /// SDK documentation).
+ ///
+ ///
+ /// If the LargeIcon parameter is specified, but the ClassGuid parameter does not supply a valid class GUID or the Icon
+ /// registry value of the class is not valid, SetupDiLoadClassIcon loads the default large icon, returns the handle for the
+ /// large icon, and, if the MiniIconIndex parameter is specified, returns the index of the default mini-icon.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiloadclassicon WINSETUPAPI BOOL
+ // SetupDiLoadClassIcon( const GUID *ClassGuid, HICON *LargeIcon, PINT MiniIconIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiLoadClassIcon")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiLoadClassIcon(in Guid ClassGuid, out HICON LargeIcon, out int MiniIconIndex);
+
+ /// The SetupDiLoadClassIcon function loads both the large and mini-icon for the specified class.
+ /// A pointer to the GUID of the class for which the icon(s) should be loaded.
+ ///
+ /// A pointer to an icon handle that receives the handle value for the loaded large icon for the specified class. This pointer is
+ /// optional and can be NULL. If the pointer is NULL, the large icon is not loaded.
+ ///
+ ///
+ /// A pointer to an INT-typed variable that receives the index of the mini-icon for the specified class. The mini-icon is stored in
+ /// the device installer's mini-icon cache. The pointer is optional and can be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// The icons of the class are either predefined and loaded from the device installer's internal cache, or they are loaded directly
+ /// from the class installer's executable. This function queries the registry value ICON in the specified class's section. If
+ /// the ICON value is specified, it indicates which mini-icon to load.
+ ///
+ ///
+ /// If the ICON value is negative, the absolute value represents a predefined icon in the class's registry. See
+ /// SetupDiDrawMiniIcon for a list of the predefined mini-icons.
+ ///
+ ///
+ /// If the ICON value is positive, it represents an icon in the class installer's executable image that will be extracted.
+ /// The value 1 is reserved. This function also uses the INSTALLER32 registry value and then the ENUMPROPPAGES32
+ /// registry value to determine which executable image to extract the icons from. For more information about these registry values,
+ /// see INF ClassInstall32 Section.
+ ///
+ ///
+ /// When a caller is finished using the icon, the caller must call DestroyIcon (which is described in the Microsoft Windows
+ /// SDK documentation).
+ ///
+ ///
+ /// If the LargeIcon parameter is specified, but the ClassGuid parameter does not supply a valid class GUID or the Icon
+ /// registry value of the class is not valid, SetupDiLoadClassIcon loads the default large icon, returns the handle for the
+ /// large icon, and, if the MiniIconIndex parameter is specified, returns the index of the default mini-icon.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiloadclassicon WINSETUPAPI BOOL
+ // SetupDiLoadClassIcon( const GUID *ClassGuid, HICON *LargeIcon, PINT MiniIconIndex );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiLoadClassIcon")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiLoadClassIcon(in Guid ClassGuid, [In, Optional] IntPtr LargeIcon, [In, Optional] IntPtr MiniIconIndex);
+
+ /// The SetupDiLoadDeviceIcon function retrieves an icon for a specified device.
+ ///
+ /// A handle to the device information set that contains the device information element that represents the device for which to
+ /// retrieve an icon.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// The width, in pixels, of the icon to be retrieved. Use the system metric index SM_CXICON to specify a default-sized icon or use
+ /// the system metric index SM_CXSMICON to specify a small icon. The system metric indexes are defined in Winuser.h, and their
+ /// associated values can be retrieved by a call to the GetSystemMetrics function. (The GetSystemMetrics function is
+ /// documented in the Microsoft Windows SDK.)
+ ///
+ ///
+ /// The height, in pixels, of the icon to be retrieved. Use SM_CXICON to specify a default-sized icon or use SM_CXSMICON to specify
+ /// a small icon.
+ ///
+ /// Not used. Must set to zero.
+ ///
+ /// A pointer to a handle to an icon that receives a handle to the icon that this function retrieves. After the application that
+ /// calls this function is finished using the icon, the application must call DestroyIcon to delete the icon. ( DestroyIcon
+ /// is documented in the Microsoft Windows SDK.)
+ ///
+ ///
+ /// SetupDiLoadDeviceIcon returns TRUE if the function succeeds in retrieving the icon for the specified device.
+ /// Otherwise, the function returns FALSE and the logged error can be retrieved by a call to GetLastError.
+ ///
+ ///
+ /// SetupDiLoadDeviceIcon attempts to retrieve an icon for the device as follows:
+ ///
+ /// -
+ ///
+ /// If the DEVPKEY_DrvPkg_Icon device property of the device includes a list of resource-identifier strings, the function attempts
+ /// to retrieve the icon that is specified by the first resource-identifier string in the list.
+ ///
+ ///
+ /// -
+ ///
+ /// If the function cannot retrieve a device-specific icon, it will then attempt to retrieve the class icon for the device. For
+ /// information about class icons, see SetupDiLoadClassIcon.
+ ///
+ ///
+ /// -
+ ///
+ /// If the function cannot retrieve the class icon for the device, it will then attempt to retrieve the icon for the Unknown device
+ /// setup class, where the icon for the Unknown device setup class includes the image of a question mark (?).
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiloaddeviceicon WINSETUPAPI BOOL
+ // SetupDiLoadDeviceIcon( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, UINT cxIcon, UINT cyIcon, DWORD Flags, HICON
+ // *hIcon );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiLoadDeviceIcon")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiLoadDeviceIcon(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, uint cxIcon, uint cyIcon,
+ [In, Optional] uint Flags, out HICON hIcon);
+
+ /// The SetupDiOpenClassRegKey function opens the setup class registry key or a specific class's subkey.
+ ///
+ /// A pointer to the GUID of the setup class whose key is to be opened. This parameter is optional and can be NULL. If this
+ /// parameter is NULL, the root of the setup class tree ( HKLM\SYSTEM\CurrentControlSet\Control\Class) is opened.
+ ///
+ ///
+ /// The registry security access for the key to be opened. For information about registry security access values of type REGSAM, see
+ /// the Microsoft Windows SDK documentation.
+ ///
+ ///
+ ///
+ /// If the function is successful, it returns a handle to an opened registry key where information about this setup class can be stored/retrieved.
+ ///
+ /// If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// This function does not create a registry key if it does not already exist.
+ /// The handle returned from this function must be closed by calling RegCloseKey.
+ /// To open the interface class registry key or a specific interface class subkey, call SetupDiOpenClassRegKeyEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopenclassregkey WINSETUPAPI HKEY
+ // SetupDiOpenClassRegKey( const GUID *ClassGuid, REGSAM samDesired );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKey")]
+ public static extern SafeRegistryHandle SetupDiOpenClassRegKey(in Guid ClassGuid, RegistryRights samDesired);
+
+ /// The SetupDiOpenClassRegKey function opens the setup class registry key or a specific class's subkey.
+ ///
+ /// A pointer to the GUID of the setup class whose key is to be opened. This parameter is optional and can be NULL. If this
+ /// parameter is NULL, the root of the setup class tree ( HKLM\SYSTEM\CurrentControlSet\Control\Class) is opened.
+ ///
+ ///
+ /// The registry security access for the key to be opened. For information about registry security access values of type REGSAM, see
+ /// the Microsoft Windows SDK documentation.
+ ///
+ ///
+ ///
+ /// If the function is successful, it returns a handle to an opened registry key where information about this setup class can be stored/retrieved.
+ ///
+ /// If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// This function does not create a registry key if it does not already exist.
+ /// The handle returned from this function must be closed by calling RegCloseKey.
+ /// To open the interface class registry key or a specific interface class subkey, call SetupDiOpenClassRegKeyEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopenclassregkey WINSETUPAPI HKEY
+ // SetupDiOpenClassRegKey( const GUID *ClassGuid, REGSAM samDesired );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKey")]
+ public static extern SafeRegistryHandle SetupDiOpenClassRegKey([In, Optional] IntPtr ClassGuid, RegistryRights samDesired);
+
+ ///
+ /// The SetupDiOpenClassRegKeyEx function opens the device setup class registry key, the device interface class registry key,
+ /// or a specific class's subkey. This function opens the specified key on the local computer or on a remote computer.
+ ///
+ ///
+ /// A pointer to the GUID of the class whose registry key is to be opened. This parameter is optional and can be NULL. If
+ /// this parameter is NULL, the root of the class tree ( HKLM\SYSTEM\CurrentControlSet\Control\Class) is opened.
+ ///
+ ///
+ /// The registry security access for the key to be opened. For information about registry security access values of type REGSAM, see
+ /// the Microsoft Windows SDK documentation.
+ ///
+ ///
+ /// The type of registry key to be opened, which is specified by one of the following:
+ /// DIOCR_INSTALLER
+ /// Open a setup class key. If ClassGuid is NULL, open the root key of the class installer branch.
+ /// DIOCR_INTERFACE
+ /// Open an interface class key. If ClassGuid is NULL, open the root key of the interface class branch.
+ ///
+ ///
+ /// Optionally points to a string that contains the name of a remote computer on which to open the specified key.
+ ///
+ /// Reserved. Must be NULL.
+ ///
+ ///
+ /// SetupDiOpenClassRegKeyEx returns a handle to an opened registry key where information about this setup class can be stored/retrieved.
+ ///
+ /// If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// SetupDiOpenClassRegKeyEx does not create a registry key if it does not already exist.
+ /// Callers of this function must close the handle returned from this function by calling RegCloseKey.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopenclassregkeyexa WINSETUPAPI HKEY
+ // SetupDiOpenClassRegKeyExA( const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKeyExA")]
+ public static extern SafeRegistryHandle SetupDiOpenClassRegKeyEx(in Guid ClassGuid, RegistryRights samDesired, DIOCR Flags,
+ [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiOpenClassRegKeyEx function opens the device setup class registry key, the device interface class registry key,
+ /// or a specific class's subkey. This function opens the specified key on the local computer or on a remote computer.
+ ///
+ ///
+ /// A pointer to the GUID of the class whose registry key is to be opened. This parameter is optional and can be NULL. If
+ /// this parameter is NULL, the root of the class tree ( HKLM\SYSTEM\CurrentControlSet\Control\Class) is opened.
+ ///
+ ///
+ /// The registry security access for the key to be opened. For information about registry security access values of type REGSAM, see
+ /// the Microsoft Windows SDK documentation.
+ ///
+ ///
+ /// The type of registry key to be opened, which is specified by one of the following:
+ /// DIOCR_INSTALLER
+ /// Open a setup class key. If ClassGuid is NULL, open the root key of the class installer branch.
+ /// DIOCR_INTERFACE
+ /// Open an interface class key. If ClassGuid is NULL, open the root key of the interface class branch.
+ ///
+ ///
+ /// Optionally points to a string that contains the name of a remote computer on which to open the specified key.
+ ///
+ /// Reserved. Must be NULL.
+ ///
+ ///
+ /// SetupDiOpenClassRegKeyEx returns a handle to an opened registry key where information about this setup class can be stored/retrieved.
+ ///
+ /// If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// SetupDiOpenClassRegKeyEx does not create a registry key if it does not already exist.
+ /// Callers of this function must close the handle returned from this function by calling RegCloseKey.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopenclassregkeyexa WINSETUPAPI HKEY
+ // SetupDiOpenClassRegKeyExA( const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKeyExA")]
+ public static extern SafeRegistryHandle SetupDiOpenClassRegKeyEx([In, Optional] IntPtr ClassGuid, RegistryRights samDesired, DIOCR Flags,
+ [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiOpenDeviceInfo function adds a device information element for a device instance to a device information set,
+ /// if one does not already exist in the device information set, and retrieves information that identifies the device information
+ /// element for the device instance in the device information set.
+ ///
+ ///
+ /// A handle to the device information set to which SetupDiOpenDeviceInfo adds a device information element, if one does not
+ /// already exist, for the device instance that is specified by DeviceInstanceId.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that supplies the device instance identifier of a device (for example,
+ /// "Root*PNP0500\0000"). If DeviceInstanceId is NULL or references a zero-length string, SetupDiOpenDeviceInfo adds a
+ /// device information element to the supplied device information set, if one does not already exist, for the root device in the
+ /// device tree.
+ ///
+ /// The handle to the top-level window to use for any user interface related to installing the device.
+ ///
+ ///
+ /// A variable of DWORD type that controls how the device information element is opened. The value of this parameter can be one or
+ /// more of the following:
+ ///
+ /// DIOD_CANCEL_REMOVE
+ ///
+ /// If this flag is specified and the device had been marked for pending removal, the operating system cancels the pending removal.
+ ///
+ /// DIOD_INHERIT_CLASSDRVS
+ ///
+ /// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with the
+ /// device information set. In addition, if there is a selected driver for the device information set, that same driver is selected
+ /// for the new device information element.
+ ///
+ /// If the device information element was already present, its class driver list, if any, is replaced with the inherited list.
+ ///
+ ///
+ /// A pointer to a caller-supplied SP_DEVINFO_DATA structure that receives information about the device information element for the
+ /// device instance that is specified by DeviceInstanceId. The caller must set cbSize to sizeof( SP_DEVINFO_DATA
+ /// ). This parameter is optional and can be NULL.
+ ///
+ ///
+ /// SetupDiOpenDeviceInfo returns TRUE if it is successful. Otherwise, the function returns FALSE and the
+ /// logged error can be retrieved with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If this device instance is being added to a set that has an associated class, the device class must be the same or the call will
+ /// fail. In this case, a call to GetLastError returns ERROR_CLASS_MISMATCH.
+ ///
+ ///
+ /// If the new device information element is successfully opened but the caller-supplied DeviceInfoData buffer is invalid, this
+ /// function returns FALSE. In this case, a call to GetLastError returns ERROR_INVALID_USER_BUFFER. However, the device
+ /// information element is added as a new member of the set anyway.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopendeviceinfoa WINSETUPAPI BOOL
+ // SetupDiOpenDeviceInfoA( HDEVINFO DeviceInfoSet, PCSTR DeviceInstanceId, HWND hwndParent, DWORD OpenFlags, PSP_DEVINFO_DATA
+ // DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInfoA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiOpenDeviceInfo(HDEVINFO DeviceInfoSet, [MarshalAs(UnmanagedType.LPTStr)] string DeviceInstanceId,
+ [In, Optional] HWND hwndParent, DIOD OpenFlags, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiOpenDeviceInterface function retrieves information about a device interface and adds the interface to the
+ /// specified device information set for a local system or a remote system.
+ ///
+ ///
+ /// A pointer to a device information set that contains, or will contain, a device information element that represents the device
+ /// that supports the interface to open.
+ ///
+ ///
+ /// A pointer to a NULL-terminated string that supplies the name of the device interface to be opened. This name is a Win32 device
+ /// path that is typically received in a PnP notification structure or obtained by a previous call to SetupDiEnumDeviceInterfaces
+ /// and its related functions.
+ ///
+ ///
+ /// Flags that determine how the device interface element is to be opened. The only valid flag is as follows:
+ /// DIODI_NO_ADD
+ ///
+ /// Specifies that the device information element for the underlying device will not be created if that element is not already
+ /// present in the specified device information set. For more information, see the following Remarks section.
+ ///
+ ///
+ ///
+ /// A pointer to a caller-initialized SP_DEVICE_INTERFACE_DATA structure that receives the requested interface data. This pointer is
+ /// optional and can be NULL. If a buffer is supplied, the caller must set the cbSize member of the structure to
+ /// sizeof( SP_DEVICE_INTERFACE_DATA ) before calling SetupDiOpenDeviceInterface. For more information, see the
+ /// following Remarks section.
+ ///
+ ///
+ /// SetupDiOpenDeviceInterface returns TRUE if the function completed without error. If the function completed with an
+ /// error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ ///
+ /// If a device interface element for the interface already exists in DeviceInfoSet, SetupDiOpenDeviceInterface updates the
+ /// flags. Therefore, this function can be used to update the flags for a device interface. For example, an interface might have
+ /// been inactive when it was first opened, but has subsequently become active. If the device information element for the underlying
+ /// device is not already present in DeviceInfoSet, this function creates one and adds it to DeviceInfoSet.
+ ///
+ ///
+ /// If the function successfully opens the new device interface but the caller did not supply a valid structure in the
+ /// DeviceInterfaceData parameter, the function will return FALSE and a subsequent call to GetLastError will return
+ /// ERROR_INVALID_USER_BUFFER. However, in this situation, SetupDiOpenDeviceInterface does add the requested interface to the
+ /// device information set.
+ ///
+ ///
+ /// If the new device interface is successfully opened, but the caller-supplied DeviceInterfaceData buffer is invalid, this function
+ /// returns FALSE and GetLastError returns ERROR_INVALID_USER_BUFFER. The caller's buffer error does not prevent the
+ /// interface from being opened.
+ ///
+ ///
+ /// If the DIODI_NO_ADD flag is specified for the OpenFlags parameter, and a device information element for the underlying device is
+ /// not already present in the specified device information set, this function returns FALSE and GetLastError returns ERROR_NO_SUCH_DEVICE_INTERFACE.
+ ///
+ ///
+ /// When the application has finished using the information that SetupDiOpenDeviceInterface retrieved , the
+ /// application must call SetupDiDeleteDeviceInterfaceData.
+ ///
+ ///
+ /// MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINKattribute can be passed in as the value of the DevicePath argument of the
+ /// SetupDiOpenDeviceInterface function.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopendeviceinterfacew WINSETUPAPI BOOL
+ // SetupDiOpenDeviceInterfaceW( HDEVINFO DeviceInfoSet, PCWSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA
+ // DeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInterfaceW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiOpenDeviceInterface(HDEVINFO DeviceInfoSet, [MarshalAs(UnmanagedType.LPTStr)] string DevicePath,
+ DIODI OpenFlags, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
+
+ ///
+ /// The SetupDiOpenDeviceInterfaceRegKey function opens the registry subkey that is used by applications and drivers to store
+ /// information that is specific to a device interface.
+ ///
+ ///
+ /// A pointer to a device information set that contains the device interface for which to open a registry subkey.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface. This pointer can be returned by
+ /// SetupDiCreateDeviceInterface or SetupDiEnumDeviceInterfaces.
+ ///
+ /// Reserved. Must be zero.
+ ///
+ /// The requested registry security access to the registry subkey. For information about registry security access values of type
+ /// REGSAM, see the Microsoft Windows SDK documentation.
+ ///
+ ///
+ /// SetupDiOpenDeviceInterfaceRegKey returns a handle to the opened registry key. If the function fails, it returns
+ /// INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// Close the handle returned from by function by calling RegCloseKey.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopendeviceinterfaceregkey WINSETUPAPI HKEY
+ // SetupDiOpenDeviceInterfaceRegKey( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM
+ // samDesired );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInterfaceRegKey")]
+ public static extern SafeRegistryHandle SetupDiOpenDeviceInterfaceRegKey(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [In, Optional] uint Reserved, RegistryRights samDesired);
+
+ /// The SetupDiOpenDevRegKey function opens a registry key for device-specific configuration information.
+ ///
+ /// A handle to the device information set that contains a device information element that represents the device for which to open a
+ /// registry key.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ ///
+ /// The scope of the registry key to open. The scope determines where the information is stored. The scope can be global or specific
+ /// to a hardware profile. The scope is specified by one of the following values:
+ ///
+ /// DICS_FLAG_GLOBAL
+ ///
+ /// Open a key to store global configuration information. This information is not specific to a particular hardware profile. This
+ /// opens a key that is rooted at HKEY_LOCAL_MACHINE. The exact key opened depends on the value of the KeyType parameter.
+ ///
+ /// DICS_FLAG_CONFIGSPECIFIC
+ ///
+ /// Open a key to store hardware profile-specific configuration information. This key is rooted at one of the hardware-profile
+ /// specific branches, instead of HKEY_LOCAL_MACHINE. The exact key opened depends on the value of the KeyType parameter.
+ ///
+ ///
+ ///
+ /// A hardware profile value, which is set as follows:
+ ///
+ /// -
+ /// If Scope is set to DICS_FLAG_CONFIGSPECIFIC, HwProfile specifies the hardware profile of the key that is to be opened.
+ ///
+ /// -
+ /// If HwProfile is 0, the key for the current hardware profile is opened.
+ ///
+ /// -
+ /// If Scope is DICS_FLAG_GLOBAL, HwProfile is ignored.
+ ///
+ ///
+ ///
+ ///
+ /// The type of registry storage key to open, which can be one of the following values:
+ /// DIREG_DEV
+ /// Open a hardware key for the device.
+ /// DIREG_DRV
+ /// Open a software key for the device.
+ /// For more information about a device's hardware and software keys, see Registry Trees and Keys for Devices and Drivers.
+ ///
+ ///
+ /// The registry security access that is required for the requested key. For information about registry security access values of
+ /// type REGSAM, see the Microsoft Windows SDK documentation.
+ ///
+ ///
+ ///
+ /// If the function is successful, it returns a handle to an opened registry key where private configuration data about this device
+ /// instance can be stored/retrieved.
+ ///
+ /// If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
+ ///
+ ///
+ ///
+ /// Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a
+ /// member of the Administrators group.
+ ///
+ /// Close the handle returned from this function by calling RegCloseKey.
+ ///
+ /// The specified device instance must be registered before this function is called. However, be aware that the operating system
+ /// automatically registers PnP device instances. For information about how to register non-PnP device instances, see SetupDiRegisterDeviceInfo.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiopendevregkey WINSETUPAPI HKEY
+ // SetupDiOpenDevRegKey( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType,
+ // REGSAM samDesired );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDevRegKey")]
+ public static extern SafeRegistryHandle SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ DICS_FLAG Scope, uint HwProfile, DIREG KeyType, RegistryRights samDesired);
+
+ /// The SetupDiRegisterCoDeviceInstallers function is the default handler for DIF_REGISTER_COINSTALLERS.
+ ///
+ /// A handle to the device information set that contains a device information element that represents the device for which to
+ /// register co-installers. The device information set must not contain any remote elements.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ ///
+ /// SetupDiRegisterCoDeviceInstallers returns TRUE if the function succeeds. If the function returns FALSE,
+ /// call GetLastError for extended error information.
+ ///
+ ///
+ /// The caller of SetupDiRegisterCoDeviceInstallers must be a member of the Administrators group.
+ ///
+ /// Note Only a class installer should call SetupDiRegisterCoDeviceInstallers and only in those situations where the
+ /// class installer must perform co-installer registration operations after SetupDiRegisterCoDeviceInstallers completes the
+ /// default co-installer registration operation. In such situations, the class installer must directly call
+ /// SetupDiRegisterCoDeviceInstallers when the installer processes a DIF_REGISTER_COINSTALLERS request. For more information
+ /// about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ /// SetupDiRegisterCoDeviceInstallers reads the INF file for the device specified by DeviceInfoData and creates registry
+ /// entries to register any device-specific co-installers listed in the INF file. Co-installers are listed in an INF
+ /// DDInstall.CoInstallers section. This function also copies the files for the co-installers, unless the DI_NOFILECOPY flag is set.
+ ///
+ ///
+ /// If there is no driver selected, or the device has an INF file for Windows 9x or Millennium Edition, this function does not
+ /// register any co-installers.
+ ///
+ ///
+ /// Registering a new device-specific co-installer invalidates the Device Installer's current list of co-installers. After a
+ /// successful registration, the Device Installer updates its list of co-installers.
+ ///
+ /// This function only registers device-specific co-installers, not class co-installers.
+ /// For more information about how to write and register device-specific co-installers, see Writing a Co-installer.
+ /// The device information set specified by DeviceInfoSet must only contain elements on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiregistercodeviceinstallers WINSETUPAPI BOOL
+ // SetupDiRegisterCoDeviceInstallers( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRegisterCoDeviceInstallers")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRegisterCoDeviceInstallers(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiRegisterDeviceInfo function is the default handler for the DIF_REGISTERDEVICE request.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device to register. The
+ /// device information set must not contain any remote elements.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoData. DevInst might be updated with a new handle value upon return.
+ ///
+ ///
+ /// A flag value that controls how the device is registered, which can be zero or the following value:
+ /// SPRDI_FIND_DUPS
+ ///
+ /// Search for a previously-existing device instance that corresponds to the device that is represented by DeviceInfoData. If this
+ /// flag is not specified, the device instance is registered regardless of whether a device instance already exists for it.
+ ///
+ /// If the caller supplies CompareProc, the caller must also set this flag.
+ ///
+ ///
+ /// A pointer to a comparison callback function to use in duplicate detection. This parameter is optional and can be NULL. If
+ /// this parameter is specified, the callback function is called for each device instance that is of the same class as the device
+ /// instance that is being registered.
+ ///
+ /// The compare function must return ERROR_DUPLICATE_FOUND if it finds that the two devices are duplicates. Otherwise, it should
+ /// return NO_ERROR. If some other error is encountered, the callback function should return the appropriate ERROR_* code to
+ /// indicate the failure.
+ ///
+ ///
+ /// If CompareProc is not specified and duplication detection is requested, a default comparison behavior is used. The default is to
+ /// compare the new device's detect signature with the detect signature of all other devices in the class. The detect signature is
+ /// contained in the class-specific resource descriptor of the device's boot log configuration.
+ ///
+ ///
+ ///
+ /// A pointer to a caller-supplied context buffer that is passed into the callback function. This parameter is ignored if
+ /// CompareProc is not specified.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure to receive information about a duplicate device instance, if any, discovered as a
+ /// result of attempting to register this device. This parameter is optional and can be NULL. If this parameter is specified,
+ /// the caller must set DupDeviceInfoData. cbSize to sizeof(SP_DEVINFO_DATA). This will be filled in if the function
+ /// returns FALSE, and GetLastError returns ERROR_DUPLICATE_FOUND. This device information element is added as a member of
+ /// the specified DeviceInfoSet, if not already a member. If DupDeviceInfoData is not specified, the duplicate is not added to the
+ /// device information set.
+ ///
+ /// If you call this function when handling a DIF_REGISTERDEVICE request, the DupDeviceInfoData parameter must be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiRegisterDeviceInfo is primarily designed to register a non-PnP device with the Plug and Play (PnP) manager on a
+ /// local computer. Although SetupDiRegisterDeviceInfo will not fail if the device information set is for a remote computer,
+ /// the result is of limited use because the device information set cannot subsequently be used with DIF_Xxx installation requests
+ /// or SetupDi Xxx functions that do not support operations on a remote computer. For example, calling
+ /// SetupDiCreateDevRegKey to execute an INF section for a newly registered device on a remote computer will fail.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiRegisterDeviceInfo and only in those situations where the class
+ /// installer must perform device registration operations after SetupDiRegisterDeviceInfo completes the default device
+ /// registration operation. In such situations, the class installer must directly call SetupDiRegisterDeviceInfo when the
+ /// installer processes a DIF_REGISTERDEVICE request. For more information about calling the default handler, see Calling Default
+ /// DIF Code Handlers.
+ ///
+ ///
+ /// After registering a device information element, the caller should update any stored copies of the DevInst handle
+ /// associated with this device. This is necessary because the handle value might have changed during registration. The caller does
+ /// not have to retrieve the SP_DEVINFO_DATA structure again because the DevInst field of the structure is updated to reflect
+ /// the current value of the handle.
+ ///
+ ///
+ /// Do not directly call this function for PnP device instances. PnP device instances are automatically registered by the operating
+ /// system. However, you must register non-PnP device instances in one of the following ways:
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application uses a DIF_DETECT request to successfully detect a device, it should also use a
+ /// DIF_REGISTERDEVICE request to register the device instance. The request should be handled in the default manner. (By default,
+ /// SetupDiCallClassInstaller first calls the class installer and class co-installers to do duplicate detection and register the
+ /// device instance. If these installers do not register the device instance, SetupDiCallClassInstaller calls
+ /// SetupDiRegisterDeviceInfo to do duplicate detection and register the device instance.)
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application creates a device instance (for example, by calling SetupDiCreateDeviceInfo) but does not do
+ /// duplicate detection, your installation application should use a DIF_REGISTERDEVICE request to register the device instance. The
+ /// request should be handled in the default manner as described earlier.
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application creates a new device and does duplicate detection, your installation application should use a
+ /// DIF_REGISTERDEVICE request but should prevent SetupDiCallClassInstaller from calling SetupDiRegisterDeviceInfo. To
+ /// prevent SetupDiCallClassInstaller from calling SetupDiRegisterDeviceInfo, set the DI_NODI_DEFAULTACTION flag in
+ /// the Flags member of the SP_DEVINSTALL_PARAMS structure for the device instance. The caller of
+ /// SetupDiRegisterDeviceInfo must be a member of the Administrators group.
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiregisterdeviceinfo WINSETUPAPI BOOL
+ // SetupDiRegisterDeviceInfo( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc,
+ // PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRegisterDeviceInfo")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPRDI Flags,
+ [In, Optional] PSP_DETSIG_CMPPROC CompareProc, [In, Optional] IntPtr CompareContext, ref SP_DEVINFO_DATA DupDeviceInfoData);
+
+ /// The SetupDiRegisterDeviceInfo function is the default handler for the DIF_REGISTERDEVICE request.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device to register. The
+ /// device information set must not contain any remote elements.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoData. DevInst might be updated with a new handle value upon return.
+ ///
+ ///
+ /// A flag value that controls how the device is registered, which can be zero or the following value:
+ /// SPRDI_FIND_DUPS
+ ///
+ /// Search for a previously-existing device instance that corresponds to the device that is represented by DeviceInfoData. If this
+ /// flag is not specified, the device instance is registered regardless of whether a device instance already exists for it.
+ ///
+ /// If the caller supplies CompareProc, the caller must also set this flag.
+ ///
+ ///
+ /// A pointer to a comparison callback function to use in duplicate detection. This parameter is optional and can be NULL. If
+ /// this parameter is specified, the callback function is called for each device instance that is of the same class as the device
+ /// instance that is being registered.
+ ///
+ /// The compare function must return ERROR_DUPLICATE_FOUND if it finds that the two devices are duplicates. Otherwise, it should
+ /// return NO_ERROR. If some other error is encountered, the callback function should return the appropriate ERROR_* code to
+ /// indicate the failure.
+ ///
+ ///
+ /// If CompareProc is not specified and duplication detection is requested, a default comparison behavior is used. The default is to
+ /// compare the new device's detect signature with the detect signature of all other devices in the class. The detect signature is
+ /// contained in the class-specific resource descriptor of the device's boot log configuration.
+ ///
+ ///
+ ///
+ /// A pointer to a caller-supplied context buffer that is passed into the callback function. This parameter is ignored if
+ /// CompareProc is not specified.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure to receive information about a duplicate device instance, if any, discovered as a
+ /// result of attempting to register this device. This parameter is optional and can be NULL. If this parameter is specified,
+ /// the caller must set DupDeviceInfoData. cbSize to sizeof(SP_DEVINFO_DATA). This will be filled in if the function
+ /// returns FALSE, and GetLastError returns ERROR_DUPLICATE_FOUND. This device information element is added as a member of
+ /// the specified DeviceInfoSet, if not already a member. If DupDeviceInfoData is not specified, the duplicate is not added to the
+ /// device information set.
+ ///
+ /// If you call this function when handling a DIF_REGISTERDEVICE request, the DupDeviceInfoData parameter must be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiRegisterDeviceInfo is primarily designed to register a non-PnP device with the Plug and Play (PnP) manager on a
+ /// local computer. Although SetupDiRegisterDeviceInfo will not fail if the device information set is for a remote computer,
+ /// the result is of limited use because the device information set cannot subsequently be used with DIF_Xxx installation requests
+ /// or SetupDi Xxx functions that do not support operations on a remote computer. For example, calling
+ /// SetupDiCreateDevRegKey to execute an INF section for a newly registered device on a remote computer will fail.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiRegisterDeviceInfo and only in those situations where the class
+ /// installer must perform device registration operations after SetupDiRegisterDeviceInfo completes the default device
+ /// registration operation. In such situations, the class installer must directly call SetupDiRegisterDeviceInfo when the
+ /// installer processes a DIF_REGISTERDEVICE request. For more information about calling the default handler, see Calling Default
+ /// DIF Code Handlers.
+ ///
+ ///
+ /// After registering a device information element, the caller should update any stored copies of the DevInst handle
+ /// associated with this device. This is necessary because the handle value might have changed during registration. The caller does
+ /// not have to retrieve the SP_DEVINFO_DATA structure again because the DevInst field of the structure is updated to reflect
+ /// the current value of the handle.
+ ///
+ ///
+ /// Do not directly call this function for PnP device instances. PnP device instances are automatically registered by the operating
+ /// system. However, you must register non-PnP device instances in one of the following ways:
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application uses a DIF_DETECT request to successfully detect a device, it should also use a
+ /// DIF_REGISTERDEVICE request to register the device instance. The request should be handled in the default manner. (By default,
+ /// SetupDiCallClassInstaller first calls the class installer and class co-installers to do duplicate detection and register the
+ /// device instance. If these installers do not register the device instance, SetupDiCallClassInstaller calls
+ /// SetupDiRegisterDeviceInfo to do duplicate detection and register the device instance.)
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application creates a device instance (for example, by calling SetupDiCreateDeviceInfo) but does not do
+ /// duplicate detection, your installation application should use a DIF_REGISTERDEVICE request to register the device instance. The
+ /// request should be handled in the default manner as described earlier.
+ ///
+ ///
+ /// -
+ ///
+ /// If your installation application creates a new device and does duplicate detection, your installation application should use a
+ /// DIF_REGISTERDEVICE request but should prevent SetupDiCallClassInstaller from calling SetupDiRegisterDeviceInfo. To
+ /// prevent SetupDiCallClassInstaller from calling SetupDiRegisterDeviceInfo, set the DI_NODI_DEFAULTACTION flag in
+ /// the Flags member of the SP_DEVINSTALL_PARAMS structure for the device instance. The caller of
+ /// SetupDiRegisterDeviceInfo must be a member of the Administrators group.
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiregisterdeviceinfo WINSETUPAPI BOOL
+ // SetupDiRegisterDeviceInfo( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc,
+ // PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRegisterDeviceInfo")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPRDI Flags,
+ [In, Optional] PSP_DETSIG_CMPPROC CompareProc, [In, Optional] IntPtr CompareContext, [In, Optional] IntPtr DupDeviceInfoData);
+
+ /// The SetupDiRemoveDevice function is the default handler for the DIF_REMOVE installation request.
+ ///
+ /// A handle to a device information set for the local system that contains a device information element that represents the device
+ /// to remove.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoSet. DevInst might be updated with a new handle value upon return. If this is a global
+ /// removal or the last hardware profile-specific removal, all traces of the device instance are deleted from the registry and the
+ /// handle will be NULL.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiRemoveDevice removes the device from the system. It deletes the device's hardware and software registry keys and
+ /// any hardware-profile-specific registry keys (configuration-specific registry keys). This function dynamically stops the device
+ /// if its DevInst is active and this is a global removal or the last configuration-specific removal. If the device cannot be
+ /// dynamically stopped, flags are set in the Install Parameter block of the device information set that eventually cause the user
+ /// to be prompted to restart the computer.
+ ///
+ ///
+ /// Device removal is either global to all hardware profiles or specific to one hardware profile as specified by the Scope
+ /// member of the SP_REMOVEDEVICE_PARAMS structure that supplies the class installation parameters for the DIF_REMOVE request.
+ /// Configuration-specific removal is only appropriate for root-enumerated devices and should only be requested by system code.
+ ///
+ /// The caller of SetupDiRemoveDevice must be a member of the Administrators group.
+ ///
+ /// Note Only a class installer should call SetupDiRemoveDevice and only in those situations where the class installer
+ /// must perform device removal operations after SetupDiRemoveDevice completes the default device removal operation. In such
+ /// situations, the class installer must directly call SetupDiRemoveDevice when the installer processes a DIF_REMOVE request.
+ /// For more information about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiremovedevice WINSETUPAPI BOOL SetupDiRemoveDevice(
+ // HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRemoveDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRemoveDevice(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiRemoveDeviceInterface function removes a registered device interface from the system.
+ ///
+ /// A pointer to the device information set that contains the device interface to remove. This handle is typically returned by SetupDiGetClassDevs.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet to remove. This pointer
+ /// is typically returned by SetupDiEnumDeviceInterfaces.
+ ///
+ ///
+ /// After the interface is removed, this function sets the SPINT_REMOVED flag in DeviceInterfaceData .Flags. It also clears
+ /// the SPINT_ACTIVE flag, but be aware that this flag should have already been cleared before this function was called.
+ ///
+ ///
+ ///
+ /// SetupDiRemoveDeviceInterface returns TRUE if the function completed without error. If the function completed with
+ /// an error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// SetupDiRemoveDeviceInterface removes the specified device interface from the system. This includes deleting the
+ /// associated registry key.
+ ///
+ /// Call SetupDiDeleteDeviceInterfaceData to delete the interface from a device information list.
+ ///
+ /// A device interface must be disabled to be removed. If the interface is enabled, this function fails and GetLastError returns
+ /// ERROR_DEVICE_INTERFACE_ACTIVE. Disable an interface by using whatever interface-specific mechanism is provided (for example, an
+ /// IOCTL). If the caller has no way to disable an interface and the interface must be removed, the caller must stop the underlying
+ /// device by using SetupDiChangeState. Stopping the device disables all the interfaces exposed by the device.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiremovedeviceinterface WINSETUPAPI BOOL
+ // SetupDiRemoveDeviceInterface( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRemoveDeviceInterface")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRemoveDeviceInterface(HDEVINFO DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
+
+ ///
+ /// The SetupDiRestartDevices function restarts a specified device or, if necessary, restarts all devices that are operated
+ /// by the same function and filter drivers that operate the specified device.
+ ///
+ ///
+ /// A handle to a device information set that contains the device information element that represents the device to restart.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure for the device information member that represents the device to restart. This
+ /// parameter is also an output parameter because SetupDiRestartDevices updates the device installation parameters for this
+ /// device information member and the status and problem code of the corresponding device instance. For more information about these
+ /// updates, see the following Remarks section.
+ ///
+ ///
+ /// If the operation succeeds, SetupDiRestartDevices returns TRUE; otherwise, the function returns FALSE and
+ /// the logged error can be retrieved by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiRestartDevices should be called only by a class installer when a class installer is handling a DIF_INSTALLDEVICE
+ /// request and only in rare situations where the class installer must perform operations after all default installation operations,
+ /// except for starting a device, have completed . For more information about calling SetupDiRestartDevices in these
+ /// situations, see DIF_INSTALLDEVICE.
+ ///
+ ///
+ /// SetupDiRestartDevices restarts only the specified device if the restart can be performed without affecting the
+ /// installation of other devices that are operated by the same function driver or filter drivers that operate the device.
+ /// Specifically, if the restart of the specified device does not copy new files or modify any files that were previously installed
+ /// for the device, SetupDiRestartDevices restarts only the specified device. Otherwise, the function restarts all devices
+ /// that are operated by the same function and filter drivers that operate the specified device.
+ ///
+ ///
+ /// SetupDiRestartDevices updates the device installation parameters and device status to reflect the result of the attempted
+ /// restart operation. For example:
+ ///
+ ///
+ /// -
+ /// If the device is started, SetupDiRestartDevices sets the device status to DN_STARTED.
+ ///
+ /// -
+ ///
+ /// If a system restart is necessary to start a device, SetupDiRestartDevices sets the DI_NEEDREBOOT flag in the Flags
+ /// member of the SP_DEVINSTALL_PARAMETER structure that is associated with the device information element and sets the problem code
+ /// for the device to CM_PROB_NEED_RESTART.
+ ///
+ ///
+ ///
+ ///
+ /// The CM_Get_DevNode_Status function retrieves the status and problem code for a device instance and the
+ /// SetupDiGetDeviceInstallParams function retrieves the device installation parameters for the device information element that
+ /// represents the device instance.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdirestartdevices WINSETUPAPI BOOL
+ // SetupDiRestartDevices( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRestartDevices")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiRestartDevices(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiSelectBestCompatDrv function is the default handler for the DIF_SELECTBESTCOMPATDRV installation request.
+ ///
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to select
+ /// the best compatible driver.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ /// SetupDiSelectBestCompatDrv selects the best driver for a device information element from the compatible driver list for
+ /// the specified device.
+ ///
+ ///
+ /// If the operation succeeds, SetupDiSelectBestCompatDrv returns TRUE. Otherwise, the function returns FALSE
+ /// and the logged error can be retrieved by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the caller of SetupDiSelectBestCompatDrv is a member of the Administrators group and the class of the device is
+ /// different that the class of the selected driver, SetupDiSelectBestCompatDrv sets the class of the device to the class of
+ /// the driver. If this behavior is not desired, call this function at a lower privilege level.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiSelectBestCompatDrv and only in those situations where the class
+ /// installer must perform driver selection operations after SetupDiSelectBestCompatDrv completes the default driver
+ /// selection operation. In such situations, the class installer must directly call SetupDiSelectBestCompatDrv when the
+ /// installer processes a DIF_SELECTBESTCOMPATDRV request. For more information about calling the default handler, see Calling
+ /// Default DIF Code Handlers.
+ ///
+ ///
+ /// SetupDiSelectBestCompatDrv is primarily designed to select the best compatible driver for a device information element on
+ /// a local computer. Although SetupDiSelectBestCompatDrv will not fail if the device information set is for a remote
+ /// computer, the result is of limited use because the device information set cannot subsequently be used as input with DIF_Xxx
+ /// installation requests or SetupDi Xxx functions that do not support operations for a remote computer. In particular, the
+ /// device information set cannot subsequently be used as input with a DIF_INSTALLDEVICE installation request to install a device on
+ /// a remote computer.
+ ///
+ /// For information about how the best driver is selected, see How Windows Selects Drivers.
+ /// To get the selected driver for a device, call SetupDiGetSelectedDriver.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectbestcompatdrv WINSETUPAPI BOOL
+ // SetupDiSelectBestCompatDrv( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectBestCompatDrv")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectBestCompatDrv(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiSelectBestCompatDrv function is the default handler for the DIF_SELECTBESTCOMPATDRV installation request.
+ ///
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to select
+ /// the best compatible driver.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
+ /// SetupDiSelectBestCompatDrv selects the best driver for a device information element from the compatible driver list for
+ /// the specified device.
+ ///
+ ///
+ /// If the operation succeeds, SetupDiSelectBestCompatDrv returns TRUE. Otherwise, the function returns FALSE
+ /// and the logged error can be retrieved by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the caller of SetupDiSelectBestCompatDrv is a member of the Administrators group and the class of the device is
+ /// different that the class of the selected driver, SetupDiSelectBestCompatDrv sets the class of the device to the class of
+ /// the driver. If this behavior is not desired, call this function at a lower privilege level.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiSelectBestCompatDrv and only in those situations where the class
+ /// installer must perform driver selection operations after SetupDiSelectBestCompatDrv completes the default driver
+ /// selection operation. In such situations, the class installer must directly call SetupDiSelectBestCompatDrv when the
+ /// installer processes a DIF_SELECTBESTCOMPATDRV request. For more information about calling the default handler, see Calling
+ /// Default DIF Code Handlers.
+ ///
+ ///
+ /// SetupDiSelectBestCompatDrv is primarily designed to select the best compatible driver for a device information element on
+ /// a local computer. Although SetupDiSelectBestCompatDrv will not fail if the device information set is for a remote
+ /// computer, the result is of limited use because the device information set cannot subsequently be used as input with DIF_Xxx
+ /// installation requests or SetupDi Xxx functions that do not support operations for a remote computer. In particular, the
+ /// device information set cannot subsequently be used as input with a DIF_INSTALLDEVICE installation request to install a device on
+ /// a remote computer.
+ ///
+ /// For information about how the best driver is selected, see How Windows Selects Drivers.
+ /// To get the selected driver for a device, call SetupDiGetSelectedDriver.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectbestcompatdrv WINSETUPAPI BOOL
+ // SetupDiSelectBestCompatDrv( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectBestCompatDrv")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectBestCompatDrv(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
+
+ /// The SetupDiSelectDevice function is the default handler for the DIF_SELECTDEVICE request.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to select a driver.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element. This parameter is optional and can be
+ /// NULL. If this parameter is specified, SetupDiSelectDevice selects the driver for the specified device and sets
+ /// DeviceInfoData. ClassGuid to the GUID of the device setup class for the selected driver. If this parameter is
+ /// NULL, SetupDiSelectDevice sets the selected driver in the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiSelectDevice handles the user interface that allows the user to select a driver for the specified device, or a
+ /// device information set if a device is not specified. By setting the Flags field of the SP_DEVINSTALL_PARAMS structure for
+ /// the device, or the device information set if a device is not specified, the caller can specify special handling of the user
+ /// interface, for example, to allow users to select a driver from an OEM installation disk.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiSelectDevice and only in those situations where the class installer
+ /// must perform driver selection operations after SetupDiSelectDevice completes the default driver selection operation. In
+ /// such situations, the class installer must directly call SetupDiSelectDevice when the installer processes a
+ /// DIF_SELECTDEVICE request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ /// SetupDiSelectDevice is primarily designed to select a driver for a device on a local computer before installing the
+ /// device. Although SetupDiSelectDevice will not fail if the device information set is for a remote computer, the result is
+ /// of limited use because the device information set cannot subsequently be used with DIF_Xxx installation requests or
+ /// SetupDi Xxx functions that do not support operations on a remote computer. In particular, the device information set
+ /// cannot be used as input with a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectdevice WINSETUPAPI BOOL SetupDiSelectDevice(
+ // HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectDevice(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ /// The SetupDiSelectDevice function is the default handler for the DIF_SELECTDEVICE request.
+ ///
+ /// A handle to a device information set that contains a device information element that represents the device for which to select a driver.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element. This parameter is optional and can be
+ /// NULL. If this parameter is specified, SetupDiSelectDevice selects the driver for the specified device and sets
+ /// DeviceInfoData. ClassGuid to the GUID of the device setup class for the selected driver. If this parameter is
+ /// NULL, SetupDiSelectDevice sets the selected driver in the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiSelectDevice handles the user interface that allows the user to select a driver for the specified device, or a
+ /// device information set if a device is not specified. By setting the Flags field of the SP_DEVINSTALL_PARAMS structure for
+ /// the device, or the device information set if a device is not specified, the caller can specify special handling of the user
+ /// interface, for example, to allow users to select a driver from an OEM installation disk.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiSelectDevice and only in those situations where the class installer
+ /// must perform driver selection operations after SetupDiSelectDevice completes the default driver selection operation. In
+ /// such situations, the class installer must directly call SetupDiSelectDevice when the installer processes a
+ /// DIF_SELECTDEVICE request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ /// SetupDiSelectDevice is primarily designed to select a driver for a device on a local computer before installing the
+ /// device. Although SetupDiSelectDevice will not fail if the device information set is for a remote computer, the result is
+ /// of limited use because the device information set cannot subsequently be used with DIF_Xxx installation requests or
+ /// SetupDi Xxx functions that do not support operations on a remote computer. In particular, the device information set
+ /// cannot be used as input with a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectdevice WINSETUPAPI BOOL SetupDiSelectDevice(
+ // HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectDevice(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
+
+ ///
+ /// The SetupDiSelectOEMDrv function selects a driver for a device information set or a particular device information element
+ /// that uses an OEM path supplied by the user.
+ ///
+ ///
+ /// A window handle that will be the parent of any dialogs created during the processing of this function. This parameter can be
+ /// used to override the hwndParent field in the installation parameters block of the specified device information set or element.
+ ///
+ /// A handle to the device information set for which to select a driver.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiSelectOEMDrv associates the selected driver with
+ /// the specified device. If this parameter is NULL, SetupDiSelectOEMDrv associates the selected driver with the
+ /// global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiSelectOEMDrv is primarily designed to select an OEM driver for a device on a local computer before installing the
+ /// device on that computer. Although SetupDiSelectOEMDrv will not fail if the device information set is for a remote
+ /// computer, the result is of limited use because the device information set cannot subsequently be used with DIF_Xxx installation
+ /// requests or SetupDi Xxx functions that do not support operations on a remote computer. In particular, the device
+ /// information set cannot be used as input with a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ /// SetupDiSelectOEMDrv prompts the user for the OEM path and then calls the class installer to select a driver from the OEM path.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectoemdrv WINSETUPAPI BOOL SetupDiSelectOEMDrv(
+ // HWND hwndParent, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectOEMDrv")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectOEMDrv([In, Optional] HWND hwndParent, HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiSelectOEMDrv function selects a driver for a device information set or a particular device information element
+ /// that uses an OEM path supplied by the user.
+ ///
+ ///
+ /// A window handle that will be the parent of any dialogs created during the processing of this function. This parameter can be
+ /// used to override the hwndParent field in the installation parameters block of the specified device information set or element.
+ ///
+ /// A handle to the device information set for which to select a driver.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiSelectOEMDrv associates the selected driver with
+ /// the specified device. If this parameter is NULL, SetupDiSelectOEMDrv associates the selected driver with the
+ /// global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiSelectOEMDrv is primarily designed to select an OEM driver for a device on a local computer before installing the
+ /// device on that computer. Although SetupDiSelectOEMDrv will not fail if the device information set is for a remote
+ /// computer, the result is of limited use because the device information set cannot subsequently be used with DIF_Xxx installation
+ /// requests or SetupDi Xxx functions that do not support operations on a remote computer. In particular, the device
+ /// information set cannot be used as input with a DIF_INSTALLDEVICE installation request to install a device on a remote computer.
+ ///
+ ///
+ /// SetupDiSelectOEMDrv prompts the user for the OEM path and then calls the class installer to select a driver from the OEM path.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiselectoemdrv WINSETUPAPI BOOL SetupDiSelectOEMDrv(
+ // HWND hwndParent, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSelectOEMDrv")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSelectOEMDrv([In, Optional] HWND hwndParent, HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
+
+ ///
+ /// The SetupDiSetClassInstallParams function sets or clears class install parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set for which to set class install parameters.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that represents the device for which to set class install parameters. This parameter
+ /// is optional and can be NULL. If this parameter is specified, SetupDiSetClassInstallParams sets the class
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetClassInstallParams sets the
+ /// class install parameters that are associated with DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to a buffer that contains the new class install parameters to use. The SP_CLASSINSTALL_HEADER structure at the
+ /// beginning of this buffer must have its cbSize field set to sizeof( SP_CLASSINSTALL_HEADER ) and the
+ /// InstallFunction field must be set to the DI_FUNCTION code that reflects the type of parameters contained in the rest of
+ /// the buffer.
+ ///
+ ///
+ /// If ClassInstallParams is not specified, the current class install parameters, if any, are cleared for the specified device
+ /// information set or element.
+ ///
+ ///
+ ///
+ /// The size, in bytes, of the ClassInstallParams buffer. If the buffer is not supplied (that is, the class install parameters are
+ /// being cleared), ClassInstallParamsSize must be 0.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// All parameters are validated before any changes are made. Therefore, a return value of FALSE indicates that no parameters
+ /// were modified.
+ ///
+ ///
+ /// A side effect of setting class install parameters is that the DI_CLASSINSTALLPARAMS flag is set. If the caller wants to set the
+ /// parameters, but disable their use, this flag must be cleared by a call to SetupDiSetDeviceInstallParams.
+ ///
+ /// If the class install parameters are cleared, the DI_CLASSINSTALLPARAMS flag is reset.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetclassinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetClassInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER
+ // ClassInstallParams, DWORD ClassInstallParamsSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetClassInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetClassInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ [In, Optional] IntPtr ClassInstallParams, uint ClassInstallParamsSize);
+
+ ///
+ /// The SetupDiSetClassInstallParams function sets or clears class install parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set for which to set class install parameters.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that represents the device for which to set class install parameters. This parameter
+ /// is optional and can be NULL. If this parameter is specified, SetupDiSetClassInstallParams sets the class
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetClassInstallParams sets the
+ /// class install parameters that are associated with DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to a buffer that contains the new class install parameters to use. The SP_CLASSINSTALL_HEADER structure at the
+ /// beginning of this buffer must have its cbSize field set to sizeof( SP_CLASSINSTALL_HEADER ) and the
+ /// InstallFunction field must be set to the DI_FUNCTION code that reflects the type of parameters contained in the rest of
+ /// the buffer.
+ ///
+ ///
+ /// If ClassInstallParams is not specified, the current class install parameters, if any, are cleared for the specified device
+ /// information set or element.
+ ///
+ ///
+ ///
+ /// The size, in bytes, of the ClassInstallParams buffer. If the buffer is not supplied (that is, the class install parameters are
+ /// being cleared), ClassInstallParamsSize must be 0.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// All parameters are validated before any changes are made. Therefore, a return value of FALSE indicates that no parameters
+ /// were modified.
+ ///
+ ///
+ /// A side effect of setting class install parameters is that the DI_CLASSINSTALLPARAMS flag is set. If the caller wants to set the
+ /// parameters, but disable their use, this flag must be cleared by a call to SetupDiSetDeviceInstallParams.
+ ///
+ /// If the class install parameters are cleared, the DI_CLASSINSTALLPARAMS flag is reset.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetclassinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetClassInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER
+ // ClassInstallParams, DWORD ClassInstallParamsSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetClassInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetClassInstallParams(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData,
+ [In, Optional] IntPtr ClassInstallParams, uint ClassInstallParamsSize);
+
+ ///
+ /// The SetupDiSetClassProperty function sets a class property for a device setup class or a device interface class.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the device setup class or device interface class for which to set a device property. For
+ /// information about how to specify the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the device class property to set.
+ ///
+ ///
+ /// A DEVPROPTYPE-typed value that represents the property-data-type identifier for the device class property. For more information
+ /// about the property-data-type identifier, see the Remarks section later in this topic.
+ ///
+ ///
+ /// A pointer to a buffer that contains the property value of the device class. If either the property or the data is being deleted,
+ /// this pointer must be set to NULL, and PropertyBufferSize must be set to zero. For more information about property data,
+ /// see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// One of the following values, which specifies whether the class is a device setup class or a device interface class:
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ ///
+ /// SetupDiSetClassProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error
+ /// can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// The device setup class that is specified by ClassGuid is not valid. This error can occur only if the DICLASSPROP_INSTALLER flag
+ /// is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ /// The device interface reference string is not valid. This error can occur only if the DICLASSPROP_INTERFACE flag is specified.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ ///
+ /// An unspecified internal data value was not valid. This error could be logged if the ClassGuid value is not a valid GUID or the
+ /// property value is not consistent with the property type specified by PropertyType.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// The device interface class that is specified by ClassGuid does not exist. This error can occur only if the DICLASSPROP_INTERFACE
+ /// flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// An unspecified item was not found. One possibility is that the property to be deleted does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiSetClassProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiSetClassProperty.
+ /// A caller of SetupDiSetClassProperty must be a member of the Administrators group to set a device interface property.
+ /// SetupDiSetClassProperty enforces requirements on the property-data-type identifier and the property value.
+ ///
+ /// To obtain the device property keys that represent the device properties that are set for a device class on a local computer,
+ /// call SetupDiGetClassPropertyKeys.
+ ///
+ ///
+ /// To retrieve a device class property on a local computer, call SetupDiGetClassProperty, and to retrieve a device class property
+ /// on a remote computer, call SetupDiGetClassPropertyEx.
+ ///
+ /// To set a device class property on a remote computer, call SetupDiSetClassPropertyEx.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetclasspropertyw WINSETUPAPI BOOL
+ // SetupDiSetClassPropertyW( const GUID *ClassGuid, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, const PBYTE
+ // PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetClassPropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetClassProperty(in Guid ClassGuid, in DEVPROPKEY PropertyKey, DEVPROPTYPE PropertyType,
+ [In, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, DICLASSPROP Flags);
+
+ ///
+ /// The SetupDiSetClassPropertyEx function sets a device property for a device setup class or a device interface class on a
+ /// local or remote computer.
+ ///
+ ///
+ /// A pointer to a GUID that identifies the device setup class or device interface class for which to set a device property. For
+ /// information about how to specify the class type, see the Flags parameter.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the device class property to set.
+ ///
+ ///
+ /// A DEVPROPTYPE-typed value that represents the property-data-type identifier for the class property. For more information about
+ /// the property-data-type identifier, see the Remarks section later in this topic.
+ ///
+ ///
+ /// A pointer to a buffer that contains the class property value. If either the property or the property value is being deleted,
+ /// this pointer must be set to NULL, and PropertyBufferSize must be set to zero. For more information about property value
+ /// requirements, see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. The property buffer size must be consistent with the property-data-type
+ /// identifier that is supplied by PropertyType. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// One of the following values, which specifies whether the class is a device setup class or a device interface class:
+ /// DICLASSPROP_INSTALLER
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ /// DICLASSPROP_INTERFACE
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ ///
+ ///
+ /// A pointer to a NULL-terminated Unicode string that contains the UNC name, including the "\" prefix, of a computer. This pointer
+ /// can be set to NULL. If the pointer is NULL, SetupDiSetClassPropertyEx sets the class property for a class
+ /// that is installed on the local computer.
+ ///
+ /// This parameter must be set to NULL.
+ ///
+ ///
+ /// SetupDiSetClassPropertyEx returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged
+ /// error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_CLASS
+ ///
+ /// The device setup class that is specified by ClassGuid is not valid. This error can occur only if the DICLASSPROP_INSTALLER flag
+ /// is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REFERENCE_STRING
+ /// The device interface reference string is not valid. This error can occur only if the DICLASSPROP_INTERFACE flag is specified.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ ///
+ /// An unspecified internal data value was not valid. This error could be logged if either the ClassGuid value is not a valid GUID
+ /// or the property value does not match the property type specified by PropertyType.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_MACHINENAME
+ /// The computer name that is specified by MachineName is not valid.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_INTERFACE_CLASS
+ ///
+ /// The device interface class that is specified by ClassGuid does not exist. This error can occur only if the DICLASSPROP_INTERFACE
+ /// flag is specified.
+ ///
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// An unspecified item was not found. One possibility is that the property to be deleted does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiSetClassPropertyEx is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiSetClassPropertyEx.
+ /// A caller of SetupDiSetClassPropertyEx must be a member of the Administrators group to set a device interface property.
+ /// SetupDiSetClassPropertyEx enforces requirements on the property-data-type identifier and the property value.
+ ///
+ /// To obtain the device property keys that represent the device properties that are set for a device class on a remote computer,
+ /// call SetupDiGetClassPropertyKeysEx.
+ ///
+ ///
+ /// To retrieve a device class property on a local computer, call SetupDiGetClassProperty , and to retrieve a device class
+ /// property on a remote computer, call SetupDiGetClassPropertyEx.
+ ///
+ /// To set a device class property on a local computer, call SetupDiSetClassProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetclasspropertyexw WINSETUPAPI BOOL
+ // SetupDiSetClassPropertyExW( const GUID *ClassGuid, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, const PBYTE
+ // PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags, PCWSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetClassPropertyExW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetClassPropertyEx(in Guid ClassGuid, in DEVPROPKEY PropertyKey, DEVPROPTYPE PropertyType,
+ [In, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, DICLASSPROP Flags,
+ [Optional, MarshalAs(UnmanagedType.LPWStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiSetClassRegistryProperty function sets a specified device class property in the registry.
+ /// A pointer to the GUID that identifies the device class for which a property is to be set.
+ ///
+ /// A value that identifies the property to be set, which must be one of the following:
+ /// SPCRP_CHARACTERISTICS
+ ///
+ /// The caller supplies flags that specify the device characteristics for the class. For a list of characteristics flags, see the
+ /// DeviceCharacteristics parameter of IoCreateDevice. Device characteristics should be set when the device class is installed and
+ /// should not be changed after the device class is installed.
+ ///
+ /// SPCRP_DEVTYPE
+ ///
+ /// The caller supplies the device type for the class. For more information, see Specifying Device Types. Device type should be set
+ /// when a device class is installed and should not be changed after the device class is installed.
+ ///
+ /// SPCRP_EXCLUSIVE
+ ///
+ /// The caller supplies a DWORD value that specifies whether users can obtain exclusive access to devices for this class. The
+ /// supplied value is 1 if exclusive access is allowed, or zero otherwise. The exclusive setting for a device should be set when a
+ /// device class is installed and should not be changed after the device class is installed.
+ ///
+ /// SPCRP_LOWERFILTERS
+ ///
+ /// (Windows Vista and later) The caller supplies a REG_MULTI_SZ list of the service names of the lower filter drivers that are
+ /// installed for the device setup class. For more information about how to install a class filter driver, see Installing a Filter
+ /// Driver and INF ClassInstall32 Section.
+ ///
+ /// SPCRP_SECURITY
+ ///
+ /// The caller supplies the device's security descriptor as a SECURITY_DESCRIPTOR structure in self-relative format (described in
+ /// the Microsoft Windows SDK documentation).
+ ///
+ /// SPCRP_SECURITY_SDS
+ ///
+ /// The caller supplies the device's security descriptor as a text string. For information about security descriptor strings, see
+ /// Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings, see Security
+ /// Descriptor Definition Language (Windows).
+ ///
+ /// SPCRP_UPPERFILTERS
+ ///
+ /// (Windows Vista and later) The caller supplies a REG_MULTI_SZ list of the service names of the upper filter drivers that are
+ /// installed for the device setup class. For more information about how to install a class filter driver, see Installing a Filter
+ /// Driver and INF ClassInstall32 Section.
+ ///
+ ///
+ ///
+ /// A pointer to a buffer that supplies the specified property. This parameter is optional and can be NULL.
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer.
+ ///
+ /// A pointer to a NULL-terminated string that contains the name of a remote system on which to set the specified device class
+ /// property. This parameter is optional and can be NULL. If this parameter is NULL, the property is set on the name
+ /// of the local system.
+ ///
+ /// Reserved, must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ /// To determine the data type for a device class property, call SetupDiGetClassRegistryProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetclassregistrypropertyw WINSETUPAPI BOOL
+ // SetupDiSetClassRegistryPropertyW( const GUID *ClassGuid, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize,
+ // PCWSTR MachineName, PVOID Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetClassRegistryPropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetClassRegistryProperty(in Guid ClassGuid, SPCRP Property, [In, Optional] IntPtr PropertyBuffer,
+ uint PropertyBufferSize, [Optional, MarshalAs(UnmanagedType.LPTStr)] string MachineName, [In, Optional] IntPtr Reserved);
+
+ ///
+ /// The SetupDiSetDeviceInstallParams function sets device installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set for which to set device installation parameters.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiSetDeviceInstallParams sets the
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetDeviceInstallParams sets
+ /// the installation parameters that are associated with the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DEVINSTALL_PARAMS structure that contains the new values of the parameters. The DeviceInstallParams.
+ /// cbSize must be set to the size, in bytes, of the structure before this function is called.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// All parameters are validated before any changes are made. Therefore, a return value of FALSE indicates that no parameters
+ /// were modified.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdeviceinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetDeviceInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A
+ // DeviceInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDeviceInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ in SP_DEVINSTALL_PARAMS DeviceInstallParams);
+
+ ///
+ /// The SetupDiSetDeviceInstallParams function sets device installation parameters for a device information set or a
+ /// particular device information element.
+ ///
+ /// A handle to the device information set for which to set device installation parameters.
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiSetDeviceInstallParams sets the
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetDeviceInstallParams sets
+ /// the installation parameters that are associated with the global class driver list for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DEVINSTALL_PARAMS structure that contains the new values of the parameters. The DeviceInstallParams.
+ /// cbSize must be set to the size, in bytes, of the structure before this function is called.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// All parameters are validated before any changes are made. Therefore, a return value of FALSE indicates that no parameters
+ /// were modified.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdeviceinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetDeviceInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A
+ // DeviceInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDeviceInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceInstallParams(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData,
+ in SP_DEVINSTALL_PARAMS DeviceInstallParams);
+
+ ///
+ /// The SetupDiSetDeviceInterfaceDefault function sets a device interface as the default interface for a device interface class.
+ ///
+ ///
+ /// A handle to the device information set that contains the device interface to set as the default for a device interface class.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet.
+ ///
+ /// Not used, must be zero.
+ /// Reserved for future use, must be NULL.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// A caller must have Administrator privileges to set the default interface for a device interface class. However, if the requested
+ /// default interface is the same as the currently set default interface, the function returns TRUE regardless of whether the
+ /// caller has Administrator privileges.
+ ///
+ ///
+ /// If the function successfully sets the specified device interface as the default for the device class, it updates the Flags
+ /// member of the supplied SP_DEVICE_INTERFACE_DATA structure.
+ ///
+ ///
+ /// Call SetupDiGetClassDevs to obtain a DevInfoSet handle to a device information set that contains the device interface to set as
+ /// the default for a device interface class. To obtain the DeviceInterfaceData pointer to the device interface element, call
+ /// SetupDiEnumDeviceInterfaces to enumerate the interfaces in the device information set. To retrieve information about an
+ /// enumerated interface, call SetupDiGetDeviceInterfaceDetail.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdeviceinterfacedefault WINSETUPAPI BOOL
+ // SetupDiSetDeviceInterfaceDefault( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Flags, PVOID
+ // Reserved );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDeviceInterfaceDefault")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceInterfaceDefault(HDEVINFO DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ [In, Optional] uint Flags, [In, Optional] IntPtr Reserved);
+
+ /// The SetupDiSetDeviceInterfaceProperty function sets a device property of a device interface.
+ ///
+ /// A handle to a device information set that contains the device interface for which to set a device interface property.
+ ///
+ ///
+ /// A pointer to an SP_DEVICE_INTERFACE_DATA structure that represents the device interface for which to set a device interface property.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the device interface property to set.
+ ///
+ ///
+ /// A DEVPROPTYPE-typed value that represents the property-data-type identifier of the device interface property to set. For more
+ /// information about the property-data-type identifier, see the Remarks section later in this topic.
+ ///
+ ///
+ /// A pointer to a buffer that contains the device interface property value. If either the property or the interface value is being
+ /// deleted, this pointer must be set to NULL, and PropertyBufferSize must be set to zero. For more information about
+ /// property value data, see the Remarks section later in this topic.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. The property buffer size must be consistent with the property-data-type
+ /// identifier that is supplied by PropertyType. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
+ ///
+ /// Must be set to zero.
+ ///
+ ///
+ /// SetupDiSetDeviceInterfaceProperty returns TRUE if it is successful. Otherwise, this function returns FALSE,
+ /// and the logged error can be retrieved by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ ///
+ /// A supplied parameter is not valid. One possibility is that the device interface specified by DeviceInterfaceData is not valid.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ ///
+ /// An unspecified data value was not valid. This error could be logged if either the symbolic link name of the device interface is
+ /// not valid or the property-data-type identifier is not valid.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVICE_INTERFACE
+ /// The device interface that is specified by DeviceInterfaceData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// An unspecified internal element was not found. One possibility is that a property to be deleted does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiSetDeviceInterfaceProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiSetDeviceInterfaceProperty.
+ ///
+ /// A caller of SetupDiSetDeviceInterfaceProperty must be a member of the Administrators group to set a device interface property.
+ ///
+ /// SetupDiSetDeviceInterfaceProperty enforces requirements on the property-data-type identifier and the property value.
+ /// To obtain the device property keys that represent the device properties that are set for a device interface, call SetupDiGetDeviceInterfacePropertyKeys.
+ /// To retrieve a device interface property, call SetupDiGetDeviceInterfaceProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdeviceinterfacepropertyw WINSETUPAPI BOOL
+ // SetupDiSetDeviceInterfacePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, const DEVPROPKEY
+ // *PropertyKey, DEVPROPTYPE PropertyType, const PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDeviceInterfacePropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceInterfaceProperty(HDEVINFO DeviceInfoSet, in SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ in DEVPROPKEY PropertyKey, DEVPROPTYPE PropertyType, [In, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, [In, Optional] uint Flags);
+
+ /// The SetupDiSetDeviceProperty function sets a device instance property.
+ ///
+ /// A handle to a device information set. This device information set contains a device information element that represents the
+ /// device instance for which to set a device instance property.
+ ///
+ ///
+ /// A pointer to the SP_DEVINFO_DATA structure that identifies the device instance for which to set a device instance property.
+ ///
+ ///
+ /// A pointer to a DEVPROPKEY structure that represents the device property key of the device instance property to set.
+ ///
+ ///
+ /// A DEVPROPTYPE-typed value that represents the property-data-type identifier for the device instance property. For more
+ /// information, see the Remarks section later in this topic.
+ ///
+ ///
+ /// A pointer to a buffer that contains the device instance property value. If the property is being deleted or set to a NULL
+ /// value, this pointer must be NULL, and PropertyBufferSize must be set to zero.
+ ///
+ ///
+ /// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is NULL, PropertyBufferSize must be set to zero.
+ ///
+ /// This parameter must be set to zero.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error can be retrieved
+ /// by calling GetLastError.
+ ///
+ /// The following table includes some of the more common error codes that this function might log.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_FLAGS
+ /// The value of Flags is not zero.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The device information set that is specified by DevInfoSet is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// A supplied parameter is not valid. One possibility is that the device information element is not valid.
+ ///
+ /// -
+ /// ERROR_INVALID_REG_PROPERTY
+ /// The property key that is supplied by PropertyKey is not valid or the property is not writable.
+ ///
+ /// -
+ /// ERROR_INVALID_DATA
+ ///
+ /// The property-data-type identifier that is supplied by PropertyType, or the property value that is supplied by PropertyBuffer, is
+ /// not valid.
+ ///
+ ///
+ /// -
+ /// ERROR_INVALID_USER_BUFFER
+ /// A user buffer is not valid. One possibility is that PropertyBuffer is NULL, and PropertyBufferSize is not zero.
+ ///
+ /// -
+ /// ERROR_NO_SUCH_DEVINST
+ /// The device instance that is specified by DevInfoData does not exist.
+ ///
+ /// -
+ /// ERROR_INSUFFICIENT_BUFFER
+ /// An internal data buffer that was passed to a system call was too small.
+ ///
+ /// -
+ /// ERROR_NOT_ENOUGH_MEMORY
+ /// There was not enough system memory available to complete the operation.
+ ///
+ /// -
+ /// ERROR_NOT_FOUND
+ /// An unspecified internal element was not found. One possibility is that the property to be deleted does not exist.
+ ///
+ /// -
+ /// ERROR_ACCESS_DENIED
+ /// The caller does not have Administrator privileges.
+ ///
+ ///
+ ///
+ ///
+ /// SetupDiSetDeviceProperty is part of the unified device property model.
+ /// SetupAPI supports only a Unicode version of SetupDiSetDeviceProperty.
+ /// A caller of SetupDiSetDeviceProperty must be a member of the Administrators group to set a device instance property.
+ /// SetupDiSetDeviceProperty enforces requirements on the property-data-type identifier and the property value.
+ /// To obtain the device property keys for the instance device properties that are set for a device, call SetupDiGetDevicePropertyKeys.
+ /// To retrieve a device instance property, call SetupDiGetDeviceProperty.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdevicepropertyw WINSETUPAPI BOOL
+ // SetupDiSetDevicePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const DEVPROPKEY *PropertyKey, DEVPROPTYPE
+ // PropertyType, const PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Unicode)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDevicePropertyW")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceProperty(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ in DEVPROPKEY PropertyKey, DEVPROPTYPE PropertyType, [In, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize, [In, Optional] uint Flags);
+
+ /// The SetupDiSetDeviceRegistryProperty function sets a Plug and Play device property for a device.
+ ///
+ /// A handle to the device information set that contains a device information element that represents the device for which to set a
+ /// Plug and Play device property.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. If the
+ /// ClassGuid property is set, DeviceInfoData. ClassGuid is set upon return to the new class for the device.
+ ///
+ ///
+ /// One of the following values, which identifies the property to be set. For descriptions of these values, see SetupDiGetDeviceRegistryProperty.
+ ///
+ /// -
+ /// SPDRP_CONFIGFLAGS
+ ///
+ /// -
+ /// SPDRP_EXCLUSIVE
+ ///
+ /// -
+ /// SPDRP_FRIENDLYNAME
+ ///
+ /// -
+ /// SPDRP_LOCATION_INFORMATION
+ ///
+ /// -
+ /// SPDRP_LOWERFILTERS
+ ///
+ /// -
+ /// SPDRP_REMOVAL_POLICY_OVERRIDE
+ ///
+ /// -
+ /// SPDRP_SECURITY
+ ///
+ /// -
+ /// SPDRP_SECURITY_SDS
+ ///
+ /// -
+ /// SPDRP_UI_NUMBER_DESC_FORMAT
+ ///
+ /// -
+ /// SPDRP_UPPERFILTERS
+ ///
+ ///
+ /// The following values are reserved for use by the operating system and cannot be used in the Property parameter:
+ ///
+ /// -
+ /// SPDRP_ADDRESS
+ ///
+ /// -
+ /// SPDRP_BUSNUMBER
+ ///
+ /// -
+ /// SPDRP_BUSTYPEGUID
+ ///
+ /// -
+ /// SPDRP_CHARACTERISTICS
+ ///
+ /// -
+ /// SPDRP_CAPABILITIES
+ ///
+ /// -
+ /// SPDRP_CLASS
+ ///
+ /// -
+ /// SPDRP_CLASSGUID
+ ///
+ /// -
+ /// SPDRP_DEVICE_POWER_DATA
+ ///
+ /// -
+ /// SPDRP_DEVICEDESC
+ ///
+ /// -
+ /// SPDRP_DEVTYPE
+ ///
+ /// -
+ /// SPDRP_DRIVER
+ ///
+ /// -
+ /// SPDRP_ENUMERATOR_NAME
+ ///
+ /// -
+ /// SPDRP_INSTALL_STATE
+ ///
+ /// -
+ /// SPDRP_LEGACYBUSTYPE
+ ///
+ /// -
+ /// SPDRP_LOCATION_PATHS
+ ///
+ /// -
+ /// SPDRP_MFG
+ ///
+ /// -
+ /// SPDRP_PHYSICAL_DEVICE_OBJECT_NAME
+ ///
+ /// -
+ /// SPDRP_REMOVAL_POLICY
+ ///
+ /// -
+ /// SPDRP_REMOVAL_POLICY_HW_DEFAULT
+ ///
+ /// -
+ /// SPDRP_SERVICE
+ ///
+ /// -
+ /// SPDRP_UI_NUMBER
+ ///
+ ///
+ ///
+ ///
+ /// A pointer to a buffer that contains the new data for the property. If the property is being cleared, then this pointer should be
+ /// NULL and PropertyBufferSize must be zero.
+ ///
+ ///
+ /// The size, in bytes, of PropertyBuffer. If PropertyBuffer is NULL, then this field must be zero.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ /// The caller of this function must be a member of the Administrators group.
+ ///
+ /// The class name property cannot be set because it is based on the corresponding class GUID and is automatically updated when that
+ /// property is changed. When the ClassGUID property changes, SetupDiSetDeviceRegistryProperty automatically cleans up any
+ /// software keys associated with the device.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdeviceregistrypropertya WINSETUPAPI BOOL
+ // SetupDiSetDeviceRegistryPropertyA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE
+ // *PropertyBuffer, DWORD PropertyBufferSize );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDeviceRegistryPropertyA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDeviceRegistryProperty(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData,
+ SPDRP Property, [In, Optional] IntPtr PropertyBuffer, uint PropertyBufferSize);
+
+ /// The SetupDiSetDriverInstallParams function sets driver installation parameters for a driver information element.
+ ///
+ /// A handle to a device information set that contains a driver information element that represents the driver for which to set
+ /// installation parameters.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiSetDriverInstallParams sets the driver
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetDriverInstallParams sets
+ /// driver installation parameters for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver for which installation parameters are set. If DeviceInfoData
+ /// is specified, this driver must be a member of a driver list that is associated with DeviceInfoData. If DeviceInfoData is
+ /// NULL, this driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ /// A pointer to an SP_DRVINSTALL_PARAMS structure that specifies the new driver install parameters.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdriverinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetDriverInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINSTALL_PARAMS DriverInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDriverInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDriverInstallParams(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData,
+ in SP_DRVINFO_DATA_V2 DriverInfoData, in SP_DRVINSTALL_PARAMS DriverInstallParams);
+
+ /// The SetupDiSetDriverInstallParams function sets driver installation parameters for a driver information element.
+ ///
+ /// A handle to a device information set that contains a driver information element that represents the driver for which to set
+ /// installation parameters.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is
+ /// optional and can be set to NULL. If this parameter is specified, SetupDiSetDriverInstallParams sets the driver
+ /// installation parameters for the specified device. If this parameter is NULL, SetupDiSetDriverInstallParams sets
+ /// driver installation parameters for DeviceInfoSet.
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver for which installation parameters are set. If DeviceInfoData
+ /// is specified, this driver must be a member of a driver list that is associated with DeviceInfoData. If DeviceInfoData is
+ /// NULL, this driver must be a member of the global class driver list for DeviceInfoSet.
+ ///
+ /// A pointer to an SP_DRVINSTALL_PARAMS structure that specifies the new driver install parameters.
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetdriverinstallparamsa WINSETUPAPI BOOL
+ // SetupDiSetDriverInstallParamsA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData,
+ // PSP_DRVINSTALL_PARAMS DriverInstallParams );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetDriverInstallParamsA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetDriverInstallParams(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData,
+ in SP_DRVINFO_DATA_V2 DriverInfoData, in SP_DRVINSTALL_PARAMS DriverInstallParams);
+
+ ///
+ /// The SetupDiSetSelectedDevice function sets a device information element as the selected member of a device information
+ /// set. This function is typically used by an installation wizard.
+ ///
+ ///
+ /// A handle to the device information set that contains the device information element to set as the selected member of the device
+ /// information set.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet to set as the selected
+ /// member of DeviceInfoSet.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetselecteddevice WINSETUPAPI BOOL
+ // SetupDiSetSelectedDevice( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetSelectedDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetSelectedDevice(HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
+
+ ///
+ /// The SetupDiSetSelectedDriver function sets, or resets, the selected driver for a device information element or the
+ /// selected class driver for a device information set.
+ ///
+ ///
+ /// A handle to the device information set that contains the driver list from which to select a driver for a device information
+ /// element or for the device information set.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiSetSelectedDriver sets, or resets, the selected
+ /// driver for the specified device. If this parameter is NULL, SetupDiSetSelectedDriver sets, or resets, the selected
+ /// class driver for DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver to be selected. This parameter is optional and can be
+ /// NULL. If this parameter and DeviceInfoData are supplied, the specified driver must be a member of a driver list that is
+ /// associated with DeviceInfoData. If this parameter is specified and DeviceInfoData is NULL, the driver must be a member of
+ /// the global class driver list for DeviceInfoSet. If this parameter is NULL, the selected driver is reset for the device
+ /// information element, if DeviceInfoData is specified, or the device information set, if DeviceInfoData is NULL.
+ ///
+ ///
+ /// If the DriverInfoData. Reserved is NULL, the caller is requesting a search for a driver node with the specified
+ /// parameters ( DriverType, Description, and ProviderName). If a match is found, that driver node is selected.
+ /// The Reserved field is updated on output to reflect the actual driver node where the match was found. If a match is not
+ /// found, the function fails and a call to GetLastError returns ERROR_INVALID_PARAMETER.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the caller of SetupDiSetSelectedDriver is a member of the Administrators group, the class of the device is set to the
+ /// class of the selected driver, provided that the two classes are different.
+ ///
+ ///
+ /// If DriverInfoData is NULL, SetupDiSetSelectedDriver resets the selected driver. As a result, there is no selected driver.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetselecteddrivera WINSETUPAPI BOOL
+ // SetupDiSetSelectedDriverA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetSelectedDriverA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetSelectedDriver(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, ref SP_DRVINFO_DATA_V2 DriverInfoData);
+
+ ///
+ /// The SetupDiSetSelectedDriver function sets, or resets, the selected driver for a device information element or the
+ /// selected class driver for a device information set.
+ ///
+ ///
+ /// A handle to the device information set that contains the driver list from which to select a driver for a device information
+ /// element or for the device information set.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is
+ /// optional and can be NULL. If this parameter is specified, SetupDiSetSelectedDriver sets, or resets, the selected
+ /// driver for the specified device. If this parameter is NULL, SetupDiSetSelectedDriver sets, or resets, the selected
+ /// class driver for DeviceInfoSet.
+ ///
+ ///
+ ///
+ /// A pointer to an SP_DRVINFO_DATA structure that specifies the driver to be selected. This parameter is optional and can be
+ /// NULL. If this parameter and DeviceInfoData are supplied, the specified driver must be a member of a driver list that is
+ /// associated with DeviceInfoData. If this parameter is specified and DeviceInfoData is NULL, the driver must be a member of
+ /// the global class driver list for DeviceInfoSet. If this parameter is NULL, the selected driver is reset for the device
+ /// information element, if DeviceInfoData is specified, or the device information set, if DeviceInfoData is NULL.
+ ///
+ ///
+ /// If the DriverInfoData. Reserved is NULL, the caller is requesting a search for a driver node with the specified
+ /// parameters ( DriverType, Description, and ProviderName). If a match is found, that driver node is selected.
+ /// The Reserved field is updated on output to reflect the actual driver node where the match was found. If a match is not
+ /// found, the function fails and a call to GetLastError returns ERROR_INVALID_PARAMETER.
+ ///
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// with a call to GetLastError.
+ ///
+ ///
+ ///
+ /// If the caller of SetupDiSetSelectedDriver is a member of the Administrators group, the class of the device is set to the
+ /// class of the selected driver, provided that the two classes are different.
+ ///
+ ///
+ /// If DriverInfoData is NULL, SetupDiSetSelectedDriver resets the selected driver. As a result, there is no selected driver.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdisetselecteddrivera WINSETUPAPI BOOL
+ // SetupDiSetSelectedDriverA( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiSetSelectedDriverA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiSetSelectedDriver(HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, [In, Optional] IntPtr DriverInfoData);
+
+ /// The SetupDiUnremoveDevice function is the default handler for the DIF_UNREMOVE installation request.
+ ///
+ /// A handle to a device information set for the local system that contains a device information element that represents a device to
+ /// restore and to restart.
+ ///
+ ///
+ /// A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT
+ /// parameter because DeviceInfoData. DevInst might be updated with a new handle value on return.
+ ///
+ ///
+ /// The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved
+ /// by a call to GetLastError.
+ ///
+ ///
+ ///
+ /// SetupDiUnremoveDevice restores a device to a hardware profile. This function starts the device, if possible, or it sets a
+ /// flag in the device install parameters that eventually causes the user to be prompted to shut down the system.
+ ///
+ ///
+ /// Note Only a class installer should call SetupDiUnremoveDevice and only in those situations where the class
+ /// installer must perform device unremove operations after SetupDiUnremoveDevice completes the default device unremove
+ /// operation. In such situations, the class installer must directly call SetupDiUnremoveDevice when the installer processes
+ /// a DIF_UNREMOVE request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
+ ///
+ ///
+ /// The device being restored must have class install parameters for DIF_UNREMOVE or the function fails and GetLastError returns ERROR_NO_CLASSINSTALL_PARAMS.
+ ///
+ /// The DeviceInfoSet must only contain elements on the local computer.
+ /// The caller of SetupDiUnremoveDevice must be a member of the Administrators group.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdiunremovedevice WINSETUPAPI BOOL
+ // SetupDiUnremoveDevice( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData );
+ [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiUnremoveDevice")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetupDiUnremoveDevice(HDEVINFO DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/SetupAPI/SetupAPI.cs b/PInvoke/SetupAPI/SetupAPI.cs
index 7f004bd7..4ab18f1f 100644
--- a/PInvoke/SetupAPI/SetupAPI.cs
+++ b/PInvoke/SetupAPI/SetupAPI.cs
@@ -25,6 +25,7 @@ namespace Vanara.PInvoke
private const int MAX_SERVICE_NAME_LEN = 256;
private const int MAX_SUBTITLE_LEN = 256;
private const int MAX_TITLE_LEN = 60;
+
/// Define maximum length of a machine name in the format expected by ConfigMgr32 CM_Connect_Machine (i.e., "\\\\MachineName\0").
private const int SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3;
@@ -1291,6 +1292,50 @@ namespace Vanara.PInvoke
DI_UNREMOVEDEVICE_CONFIGSPECIFIC = 0x00000002
}
+ ///
+ /// Flags used to control exclusion of classes from the list. If no flags are specified, all setup classes are included in the list.
+ ///
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildClassInfoList")]
+ [Flags]
+ public enum DIBCI : uint
+ {
+ /// Exclude a class if it has the NoInstallClass value entry in its registry key.
+ DIBCI_NOINSTALLCLASS = 0x00000001,
+
+ /// Exclude a class if it has the NoDisplayClass value entry in its registry key.
+ DIBCI_NODISPLAYCLASS = 0x00000002
+ }
+
+ /// A variable that controls how the device information element is created.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoA")]
+ [Flags]
+ public enum DICD : uint
+ {
+ ///
+ /// If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a
+ /// full device instance ID for the new device information element.
+ ///
+ DICD_GENERATE_ID = 0x00000001,
+
+ ///
+ /// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with
+ /// the device information set. In addition, if there is a selected driver for the device information set, that same driver is
+ /// selected for the new device information element.
+ ///
+ DICD_INHERIT_CLASSDRVS = 0x00000002
+ }
+
+ /// Specifies whether the class is a device setup class or a device interface class.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyW")]
+ public enum DICLASSPROP
+ {
+ /// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
+ DICLASSPROP_INSTALLER = 0x00000001,
+
+ /// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
+ DICLASSPROP_INTERFACE = 0x00000002,
+ }
+
/// State change action.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPCHANGE_PARAMS")]
public enum DICS : uint
@@ -1365,6 +1410,38 @@ namespace Vanara.PInvoke
DICS_FLAG_CONFIGGENERAL = 0x00000004,
}
+ /// A flag value that indicates how the requested information should be returned.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetCustomDevicePropertyA")]
+ [Flags]
+ public enum DICUSTOMDEVPROP : uint
+ {
+ ///
+ /// If set, the function retrieves both device instance-specific property values and hardware ID-specific property values,
+ /// concatenated as a REG_MULTI_SZ-typed string. (For more information, see the Remarks section on this reference page.)
+ ///
+ DICUSTOMDEVPROP_MERGE_MULTISZ = 0x00000001
+ }
+
+ /// A flag that indicates one of the following types of property sheets.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevPropertySheetsA")]
+ public enum DIGCDP_FLAG
+ {
+ ///
+ /// Basic property sheets. Supported only in Microsoft Windows 95 and Windows 98. Do not use in Windows 2000 and later versions
+ /// of Windows.
+ ///
+ DIGCDP_FLAG_BASIC = 0x00000001,
+
+ /// Advanced property sheets.
+ DIGCDP_FLAG_ADVANCED = 0x00000002,
+
+ /// Not implemented.
+ DIGCDP_FLAG_REMOTE_BASIC = 0x00000003,
+
+ /// Advanced property sheets on a remote computer.
+ DIGCDP_FLAG_REMOTE_ADVANCED = 0x00000004,
+ }
+
/// Specifies control options that filter the device information elements that are added to the device information set.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevsW")]
[Flags]
@@ -1392,6 +1469,85 @@ namespace Vanara.PInvoke
DIGCF_DEVICEINTERFACE = 0x00000010,
}
+ /// The type of registry key to be opened.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKeyExA")]
+ public enum DIOCR : uint
+ {
+ /// Open a setup class key. If ClassGuid is NULL, open the root key of the class installer branch.
+ DIOCR_INSTALLER = 0x00000001,
+
+ /// Open an interface class key. If ClassGuid is NULL, open the root key of the interface class branch.
+ DIOCR_INTERFACE = 0x00000002
+ }
+
+ /// Controls how the device information element is opened.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInfoA")]
+ [Flags]
+ public enum DIOD : uint
+ {
+ ///
+ ///
+ /// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with
+ /// the device information set. In addition, if there is a selected driver for the device information set, that same driver is
+ /// selected for the new device information element.
+ ///
+ ///
+ /// If the device information element was already present, its class driver list, if any, is replaced with the inherited list.
+ ///
+ ///
+ DIOD_INHERIT_CLASSDRVS = 0x00000002,
+
+ ///
+ /// If this flag is specified and the device had been marked for pending removal, the operating system cancels the pending removal.
+ ///
+ DIOD_CANCEL_REMOVE = 0x00000004
+ }
+
+ /// Flags that determine how the device interface element is to be opened.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInterfaceW")]
+ [Flags]
+ public enum DIODI : uint
+ {
+ ///
+ /// Specifies that the device information element for the underlying device will not be created if that element is not already
+ /// present in the specified device information set. For more information, see the following Remarks section.
+ ///
+ DIODI_NO_ADD = 0x00000001,
+ }
+
+ /// The type of registry storage key to create.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDevRegKeyA")]
+ [Flags]
+ public enum DIREG : uint
+ {
+ /// Create a hardware key for the device.
+ DIREG_DEV = 0x00000001,
+
+ /// Create a software key for the device.
+ DIREG_DRV = 0x00000002,
+
+ /// Create both a software and hardware key for the device.
+ DIREG_BOTH = 0x00000004,
+ }
+
+ /// These flags control the drawing operation.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDrawMiniIcon")]
+ [Flags]
+ public enum DMI : uint
+ {
+ /// Draw the mini-icon's mask into HDC.
+ DMI_MASK = 0x00000001,
+
+ ///
+ /// Use the system color index specified in the HIWORD of Flags as the background color. If this flag is not set, COLOR_WINDOW
+ /// is used.
+ ///
+ DMI_BKCOLOR = 0x00000002,
+
+ /// If set, SetupDiDrawMiniIcon uses the supplied rectangle and stretches the icon to fit.
+ DMI_USERECT = 0x00000004,
+ }
+
/// Flags that control functions operating on this driver.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINSTALL_PARAMS")]
[Flags]
@@ -1670,6 +1826,54 @@ namespace Vanara.PInvoke
SCWMI_CLOBBER_SECURITY = 0x00000001
}
+ /// A value that identifies the property to be retrieved.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassRegistryPropertyA")]
+ public enum SPCRP
+ {
+ ///
+ /// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the upper filter drivers that are
+ /// installed for the device setup class.
+ ///
+ SPCRP_UPPERFILTERS = 0x00000011,
+
+ ///
+ /// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the lower filter drivers that are
+ /// installed for the device setup class.
+ ///
+ SPCRP_LOWERFILTERS = 0x00000012,
+
+ ///
+ /// The function returns the device's security descriptor as a SECURITY_DESCRIPTOR structure in self-relative format (described
+ /// in the Microsoft Windows SDK documentation).
+ ///
+ SPCRP_SECURITY = 0x00000017,
+
+ ///
+ /// The function returns the device's security descriptor as a text string. For information about security descriptor strings,
+ /// see Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings, see
+ /// Security Descriptor Definition Language (Windows).
+ ///
+ SPCRP_SECURITY_SDS = 0x00000018,
+
+ ///
+ /// The function returns a DWORD value that represents the device type for the class. For more information, see Specifying
+ /// Device Types.
+ ///
+ SPCRP_DEVTYPE = 0x00000019,
+
+ ///
+ /// The function returns a DWORD value indicating whether users can obtain exclusive access to devices for this class. The
+ /// returned value is one if exclusive access is allowed, or zero otherwise.
+ ///
+ SPCRP_EXCLUSIVE = 0x0000001A,
+
+ ///
+ /// The function returns flags indicating device characteristics for the class. For a list of characteristics flags, see the
+ /// DeviceCharacteristics parameter to IoCreateDevice.
+ ///
+ SPCRP_CHARACTERISTICS = 0x0000001B,
+ }
+
/// The type of driver represented by this structure.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINFO_DATA_V2_A")]
public enum SPDIT : uint
@@ -1684,6 +1888,210 @@ namespace Vanara.PInvoke
SPDIT_COMPATDRIVER = 0x00000002,
}
+ /// Specifies the property to be retrieved or set.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceRegistryPropertyA")]
+ public enum SPDRP
+ {
+ /// The function retrieves the device's address.
+ SPDRP_ADDRESS = 0x0000001C,
+
+ /// The function retrieves the device's bus number.
+ SPDRP_BUSNUMBER = 0x00000015,
+
+ /// The function retrieves the GUID for the device's bus type.
+ SPDRP_BUSTYPEGUID = 0x00000013,
+
+ ///
+ /// The function retrieves a bitwise OR of the following CM_DEVCAP_Xxx flags in a DWORD. The device capabilities that are
+ /// represented by these flags correspond to the device capabilities that are represented by the members of the
+ /// DEVICE_CAPABILITIES structure. The CM_DEVCAP_Xxx constants are defined in Cfgmgr32.h.
+ ///
+ ///
+ /// CM_DEVCAP_Xxx flag
+ /// Corresponding DEVICE_CAPABILITIES structure member
+ ///
+ /// -
+ /// CM_DEVCAP_LOCKSUPPORTED
+ /// LockSupported
+ ///
+ /// -
+ /// CM_DEVCAP_EJECTSUPPORTED
+ /// EjectSupported
+ ///
+ /// -
+ /// CM_DEVCAP_REMOVABLE
+ /// Removable
+ ///
+ /// -
+ /// CM_DEVCAP_DOCKDEVICE
+ /// DockDevice
+ ///
+ /// -
+ /// CM_DEVCAP_UNIQUEID
+ /// UniqueID
+ ///
+ /// -
+ /// CM_DEVCAP_SILENTINSTALL
+ /// SilentInstall
+ ///
+ /// -
+ /// CM_DEVCAP_RAWDEVICEOK
+ /// RawDeviceOK
+ ///
+ /// -
+ /// CM_DEVCAP_SURPRISEREMOVALOK
+ /// SurpriseRemovalOK
+ ///
+ /// -
+ /// CM_DEVCAP_HARDWAREDISABLED
+ /// HardwareDisabled
+ ///
+ /// -
+ /// CM_DEVCAP_NONDYNAMIC
+ /// NonDynamic
+ ///
+ ///
+ ///
+ SPDRP_CAPABILITIES = 0x0000000F,
+
+ ///
+ /// The function retrieves a bitwise OR of a device's characteristics flags in a DWORD. For a description of these flags, which
+ /// are defined in Wdm.h and Ntddk.h, see the DeviceCharacteristics parameter of the IoCreateDevice function.
+ ///
+ SPDRP_CHARACTERISTICS = 0x0000001B,
+
+ /// The function retrieves a REG_SZ string that contains the device setup class of a device.
+ SPDRP_CLASS = 0x00000007,
+
+ /// The function retrieves a REG_SZ string that contains the GUID that represents the device setup class of a device.
+ SPDRP_CLASSGUID = 0x00000008,
+
+ ///
+ /// The function retrieves a REG_MULTI_SZ string that contains the list of compatible IDs for a device. For information about
+ /// compatible IDs, see Device Identification Strings.
+ ///
+ SPDRP_COMPATIBLEIDS = 0x00000002,
+
+ ///
+ /// The function retrieves a bitwise OR of a device's configuration flags in a DWORD value. The configuration flags are
+ /// represented by the CONFIGFLAG_Xxx bitmasks that are defined in Regstr.h.
+ ///
+ SPDRP_CONFIGFLAGS = 0x0000000A,
+
+ ///
+ /// (Windows XP and later) The function retrieves a CM_POWER_DATA structure that contains the device's power management information.
+ ///
+ SPDRP_DEVICE_POWER_DATA = 0x0000001E,
+
+ /// The function retrieves a REG_SZ string that contains the description of a device.
+ SPDRP_DEVICEDESC = 0x00000000,
+
+ ///
+ /// The function retrieves a DWORD value that represents the device's type. For more information, see Specifying Device Types.
+ ///
+ SPDRP_DEVTYPE = 0x00000019,
+
+ ///
+ /// The function retrieves a string that identifies the device's software key (sometimes called the driver key). For more
+ /// information about driver keys, see Registry Trees and Keys for Devices and Drivers.
+ ///
+ SPDRP_DRIVER = 0x00000009,
+
+ /// The function retrieves a REG_SZ string that contains the name of the device's enumerator.
+ SPDRP_ENUMERATOR_NAME = 0x00000016,
+
+ ///
+ /// The function retrieves a DWORD value that indicates whether a user can obtain exclusive use of the device. The returned
+ /// value is one if exclusive use is allowed, or zero otherwise. For more information, see IoCreateDevice.
+ ///
+ SPDRP_EXCLUSIVE = 0x0000001A,
+
+ /// The function retrieves a REG_SZ string that contains the friendly name of a device.
+ SPDRP_FRIENDLYNAME = 0x0000000C,
+
+ ///
+ /// The function retrieves a REG_MULTI_SZ string that contains the list of hardware IDs for a device. For information about
+ /// hardware IDs, see Device Identification Strings.
+ ///
+ SPDRP_HARDWAREID = 0x00000001,
+
+ ///
+ /// (Windows XP and later) The function retrieves a DWORD value that indicates the installation state of a device. The
+ /// installation state is represented by one of the CM_INSTALL_STATE_Xxx values that are defined in Cfgmgr32.h. The
+ /// CM_INSTALL_STATE_Xxx values correspond to the DEVICE_INSTALL_STATE enumeration values.
+ ///
+ SPDRP_INSTALL_STATE = 0x00000022,
+
+ /// The function retrieves the device's legacy bus type as an INTERFACE_TYPE value (defined in Wdm.h and Ntddk.h).
+ SPDRP_LEGACYBUSTYPE = 0x00000014,
+
+ /// The function retrieves a REG_SZ string that contains the hardware location of a device.
+ SPDRP_LOCATION_INFORMATION = 0x0000000D,
+
+ ///
+ /// (Windows Server 2003 and later) The function retrieves a REG_MULTI_SZ string that represents the location of the device in
+ /// the device tree.
+ ///
+ SPDRP_LOCATION_PATHS = 0x00000023,
+
+ /// The function retrieves a REG_MULTI_SZ string that contains the names of a device's lower-filter drivers.
+ SPDRP_LOWERFILTERS = 0x00000012,
+
+ /// The function retrieves a REG_SZ string that contains the name of the device manufacturer.
+ SPDRP_MFG = 0x0000000B,
+
+ ///
+ /// The function retrieves a REG_SZ string that contains the name that is associated with the device's PDO. For more
+ /// information, see IoCreateDevice.
+ ///
+ SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E,
+
+ ///
+ /// (Windows XP and later) The function retrieves the device's current removal policy as a DWORD that contains one of the
+ /// CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ SPDRP_REMOVAL_POLICY = 0x0000001F,
+
+ ///
+ /// (Windows XP and later) The function retrieves the device's hardware-specified default removal policy as a DWORD that
+ /// contains one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ SPDRP_REMOVAL_POLICY_HW_DEFAULT = 0x00000020,
+
+ ///
+ /// (Windows XP and later) The function retrieves the device's override removal policy (if it exists) from the registry, as a
+ /// DWORD that contains one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
+ ///
+ SPDRP_REMOVAL_POLICY_OVERRIDE = 0x00000021,
+
+ /// The function retrieves a SECURITY_DESCRIPTOR structure for a device.
+ SPDRP_SECURITY = 0x00000017,
+
+ ///
+ /// The function retrieves a REG_SZ string that contains the device's security descriptor. For information about security
+ /// descriptor strings, see Security Descriptor Definition Language (Windows). For information about the format of security
+ /// descriptor strings, see Security Descriptor Definition Language (Windows).
+ ///
+ SPDRP_SECURITY_SDS = 0x00000018,
+
+ /// The function retrieves a REG_SZ string that contains the service name for a device.
+ SPDRP_SERVICE = 0x00000004,
+
+ ///
+ /// The function retrieves a DWORD value set to the value of the UINumber member of the device's DEVICE_CAPABILITIES structure.
+ ///
+ SPDRP_UI_NUMBER = 0x00000010,
+
+ /// The function retrieves a format string (REG_SZ) used to display the UINumber value.
+ SPDRP_UI_NUMBER_DESC_FORMAT = 0x0000001D,
+
+ /// The function retrieves a REG_MULTI_SZ string that contains the names of a device's upper filter drivers.
+ SPDRP_UPPERFILTERS = 0x00000011,
+
+ /// Base ContainerID (R)
+ SPDRP_BASE_CONTAINERID = 0x00000024,
+ }
+
/// Flags for .
[Flags]
public enum SPDSL : uint
@@ -1830,6 +2238,18 @@ namespace Vanara.PInvoke
SPPSR_ENUM_ADV_DEVICE_PROPERTIES,
}
+ /// A flag value that controls how the device is registered.
+ [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRegisterDeviceInfo")]
+ [Flags]
+ public enum SPRDI : uint
+ {
+ ///
+ /// Search for a previously-existing device instance that corresponds to the device that is represented by DeviceInfoData. If
+ /// this flag is not specified, the device instance is registered regardless of whether a device instance already exists for it.
+ ///
+ SPRDI_FIND_DUPS = 0x00000001
+ }
+
///
/// For a SPFILENOTIFY_STARTREGISTRATION notification, this member is not used and should be set to SPREG_SUCCESS. For a
/// SPFILENOTIFY_ENDREGISTRATION notification, set to one of the following failure codes that indicate the result of registration.
@@ -2354,6 +2774,7 @@ namespace Vanara.PInvoke
///
public IntPtr DangerousGetHandle() => handle;
}
+
///
/// The INFCONTEXT structure stores context information that functions such as SetupGetLineText use to navigate INF files.
///
diff --git a/PInvoke/SetupAPI/Vanara.PInvoke.SetupAPI.csproj b/PInvoke/SetupAPI/Vanara.PInvoke.SetupAPI.csproj
index e0bdc4fd..c60b2808 100644
--- a/PInvoke/SetupAPI/Vanara.PInvoke.SetupAPI.csproj
+++ b/PInvoke/SetupAPI/Vanara.PInvoke.SetupAPI.csproj
@@ -13,71 +13,12 @@
Currently implements:
Functions
-DriverStoreAddDriverPackage, DriverStoreDeleteDriverPackage, DriverStoreEnumDriverPackage, DriverStoreFindDriverPackage, ExtensionPropSheetPageProc, InstallCatalog, InstallHinfSection, PnpEnumDrpFile, PnpIsFileAclIntact, PnpIsFileContentIntact, PnpIsFilePnpDriver, PnpRepairWindowsProtectedDriver, SetupAddInstallSectionToDiskSpaceList, SetupAddSectionToDiskSpaceList, SetupAddToDiskSpaceList, SetupAddToSourceList, SetupAdjustDiskSpaceList, SetupBackupError, SetupCancelTemporarySourceList, SetupCloseFileQueue, SetupCloseInfFile, SetupCloseLog, SetupCommitFileQueue, SetupConfigureWmiFromInfSection, SetupCopyError, SetupCopyOEMInf, SetupCreateDiskSpaceList, SetupDecompressOrCopyFile, SetupDefaultQueueCallback, SetupDeleteError, SetupDestroyDiskSpaceList, SetupDiApplyPowerScheme, SetupDiAskForOEMDisk, SetupDiBuildClassInfoList, SetupDiBuildClassInfoListEx, SetupDiBuildDriverInfoList, SetupDiCallClassInstaller, SetupDiCancelDriverInfoSearch, SetupDiChangeState, SetupDiClassGuidsFromName, SetupDiClassGuidsFromNameEx, SetupDiClassNameFromGuid, SetupDiClassNameFromGuidEx, SetupDiCreateDeviceInfo, SetupDiCreateDeviceInfoList, SetupDiCreateDeviceInfoListEx, SetupDiCreateDeviceInterface, SetupDiCreateDeviceInterfaceRegKey, SetupDiCreateDevRegKey, SetupDiDeleteDeviceInfo, SetupDiDeleteDeviceInterfaceData, SetupDiDeleteDeviceInterfaceRegKey, SetupDiDeleteDevRegKey, SetupDiDestroyClassImageList, SetupDiDestroyDeviceInfoList, SetupDiDestroyDriverInfoList, SetupDiDrawMiniIcon, SetupDiEnumDeviceInfo, SetupDiEnumDeviceInterfaces, SetupDiEnumDriverInfo, SetupDiGetActualModelsSection, SetupDiGetActualSectionToInstall, SetupDiGetActualSectionToInstallEx, SetupDiGetClassBitmapIndex, SetupDiGetClassDescription, SetupDiGetClassDescriptionEx, SetupDiGetClassDevPropertySheets, SetupDiGetClassDevs, SetupDiGetClassDevsEx, SetupDiGetClassImageIndex, SetupDiGetClassImageList, SetupDiGetClassImageListEx, SetupDiGetClassInstallParams, SetupDiGetClassPropertyExW, SetupDiGetClassPropertyKeys, SetupDiGetClassPropertyKeysExW, SetupDiGetClassPropertyW, SetupDiGetClassRegistryProperty, SetupDiGetCustomDeviceProperty, SetupDiGetDeviceInfoListClass, SetupDiGetDeviceInfoListDetail, SetupDiGetDeviceInstallParams, SetupDiGetDeviceInstanceId, SetupDiGetDeviceInterfaceAlias, SetupDiGetDeviceInterfaceDetail, SetupDiGetDeviceInterfacePropertyKeys, SetupDiGetDeviceInterfacePropertyW, SetupDiGetDevicePropertyKeys, SetupDiGetDevicePropertyW, SetupDiGetDeviceRegistryProperty, SetupDiGetDriverInfoDetail, SetupDiGetDriverInstallParams, SetupDiGetHwProfileFriendlyName, SetupDiGetHwProfileFriendlyNameEx, SetupDiGetHwProfileList, SetupDiGetHwProfileListEx, SetupDiGetINFClass, SetupDiGetSelectedDevice, SetupDiGetSelectedDriver, SetupDiGetWizardPage, SetupDiInstallClass, SetupDiInstallClassEx, SetupDiInstallDevice, SetupDiInstallDeviceInterfaces, SetupDiInstallDriverFiles, SetupDiLoadClassIcon, SetupDiLoadDeviceIcon, SetupDiMoveDuplicateDevice, SetupDiOpenClassRegKey, SetupDiOpenClassRegKeyEx, SetupDiOpenDeviceInfo, SetupDiOpenDeviceInterface, SetupDiOpenDeviceInterfaceRegKey, SetupDiOpenDevRegKey, SetupDiRegisterCoDeviceInstallers, SetupDiRegisterDeviceInfo, SetupDiRemoveDevice, SetupDiRemoveDeviceInterface, SetupDiReportAdditionalSoftwareRequested, SetupDiReportDeviceInstallError, SetupDiReportDriverNotFoundError, SetupDiReportDriverPackageImportationError, SetupDiReportGenericDriverInstalled, SetupDiReportPnPDeviceProblem, SetupDiRestartDevices, SetupDiSelectBestCompatDrv, SetupDiSelectDevice, SetupDiSelectOEMDrv, SetupDiSetClassInstallParams, SetupDiSetClassPropertyExW, SetupDiSetClassPropertyW, SetupDiSetClassRegistryProperty, SetupDiSetDeviceInstallParams, SetupDiSetDeviceInterfaceDefault, SetupDiSetDeviceInterfacePropertyW, SetupDiSetDevicePropertyW, SetupDiSetDeviceRegistryProperty, SetupDiSetDriverInstallParams, SetupDiSetSelectedDevice, SetupDiSetSelectedDriver, SetupDiUnremoveDevice, SetupDuplicateDiskSpaceList, SetupEnumInfSections, SetupEnumPublishedInf, SetupFindFirstLine, SetupFindNextLine, SetupFindNextMatchLine, SetupFreeSourceList, SetupGetBackupInformation, SetupGetBinaryField, SetupGetFieldCount, SetupGetFileCompressionInfo, SetupGetFileCompressionInfoEx, SetupGetFileQueueCount, SetupGetFileQueueFlags, SetupGetInfDriverStoreLocation, SetupGetInfFileList, SetupGetInfInformation, SetupGetInfPublishedName, SetupGetInfSections, SetupGetIntField, SetupGetLineByIndex, SetupGetLineCount, SetupGetLineText, SetupGetMultiSzField, SetupGetNonInteractiveMode, SetupGetSourceFileLocation, SetupGetSourceFileSize, SetupGetSourceInfo, SetupGetStringField, SetupGetTargetPath, SetupGetThreadLogToken, SetupInitDefaultQueueCallback, SetupInitDefaultQueueCallbackEx, SetupInitializeFileLog, SetupInstallFile, SetupInstallFileEx, SetupInstallFilesFromInfSection, SetupInstallFromInfSection, SetupInstallLogCloseEventGroup, SetupInstallLogCreateEventGroup, SetupInstallServicesFromInfSection, SetupInstallServicesFromInfSectionEx, SetupIterateCabinet, SetupLogError, SetupLogFile, SetupOpenAppendInfFile, SetupOpenFileQueue, SetupOpenInfFile, SetupOpenLog, SetupOpenMasterInf, SetupPrepareQueueForRestore, SetupPromptForDisk, SetupPromptReboot, SetupQueryDrivesInDiskSpaceList, SetupQueryFileLog, SetupQueryInfFileInformation, SetupQueryInfOriginalFileInformation, SetupQueryInfVersionInformation, SetupQuerySourceList, SetupQuerySpaceRequiredOnDrive, SetupQueueCopy, SetupQueueCopyIndirect, SetupQueueCopySection, SetupQueueDefaultCopy, SetupQueueDelete, SetupQueueDeleteSection, SetupQueueRename, SetupQueueRenameSection, SetupRemoveFileLogEntry, SetupRemoveFromDiskSpaceList, SetupRemoveFromSourceList, SetupRemoveInstallSectionFromDiskSpaceList, SetupRemoveSectionFromDiskSpaceList, SetupRenameError, SetupScanFileQueue, SetupSetDirectoryId, SetupSetDirectoryIdEx, SetupSetFileQueueAlternatePlatform, SetupSetFileQueueFlags, SetupSetNonInteractiveMode, SetupSetPlatformPathOverride, SetupSetSourceList, SetupSetThreadLogToken, SetupTermDefaultQueueCallback, SetupTerminateFileLog, SetupUninstallNewlyCopiedInfs, SetupUninstallOEMInf, SetupVerifyInfFile, SetupWriteTextLog, SetupWriteTextLogError, SetupWriteTextLogInfLine, VerifyCatalogFile
+DriverStoreAddDriverPackage, DriverStoreDeleteDriverPackage, DriverStoreEnumDriverPackage, DriverStoreFindDriverPackage, ExtensionPropSheetPageProc, InstallCatalog, InstallHinfSection, PnpEnumDrpFile, PnpIsFileAclIntact, PnpIsFileContentIntact, PnpIsFilePnpDriver, PnpRepairWindowsProtectedDriver, SetupAddInstallSectionToDiskSpaceList, SetupAddSectionToDiskSpaceList, SetupAddToDiskSpaceList, SetupAddToSourceList, SetupAdjustDiskSpaceList, SetupBackupError, SetupCancelTemporarySourceList, SetupCloseFileQueue, SetupCloseInfFile, SetupCloseLog, SetupCommitFileQueue, SetupConfigureWmiFromInfSection, SetupCopyError, SetupCopyOEMInf, SetupCreateDiskSpaceList, SetupDecompressOrCopyFile, SetupDefaultQueueCallback, SetupDeleteError, SetupDestroyDiskSpaceList, SetupDiApplyPowerScheme, SetupDiAskForOEMDisk, SetupDiBuildClassInfoList, SetupDiBuildClassInfoListEx, SetupDiBuildClassInfoListExAA, SetupDiBuildClassInfoListExAW, SetupDiBuildDriverInfoList, SetupDiCallClassInstaller, SetupDiCancelDriverInfoSearch, SetupDiChangeState, SetupDiClassGuidsFromName, SetupDiClassGuidsFromNameEx, SetupDiClassNameFromGuid, SetupDiClassNameFromGuidEx, SetupDiCreateDeviceInfo, SetupDiCreateDeviceInfoList, SetupDiCreateDeviceInfoListEx, SetupDiCreateDeviceInterface, SetupDiCreateDeviceInterfaceRegKey, SetupDiCreateDevRegKey, SetupDiDeleteDeviceInfo, SetupDiDeleteDeviceInterfaceData, SetupDiDeleteDeviceInterfaceRegKey, SetupDiDeleteDevRegKey, SetupDiDestroyClassImageList, SetupDiDestroyDeviceInfoList, SetupDiDestroyDriverInfoList, SetupDiDrawMiniIcon, SetupDiEnumDeviceInfo, SetupDiEnumDeviceInterfaces, SetupDiEnumDriverInfo, SetupDiGetActualModelsSection, SetupDiGetActualSectionToInstall, SetupDiGetActualSectionToInstallEx, SetupDiGetClassBitmapIndex, SetupDiGetClassDescription, SetupDiGetClassDescriptionEx, SetupDiGetClassDevPropertySheets, SetupDiGetClassDevs, SetupDiGetClassDevsEx, SetupDiGetClassImageIndex, SetupDiGetClassImageList, SetupDiGetClassImageListEx, SetupDiGetClassInstallParams, SetupDiGetClassPropertyExW, SetupDiGetClassPropertyKeys, SetupDiGetClassPropertyKeysExW, SetupDiGetClassPropertyW, SetupDiGetClassRegistryProperty, SetupDiGetCustomDeviceProperty, SetupDiGetDeviceInfoListClass, SetupDiGetDeviceInfoListDetail, SetupDiGetDeviceInstallParams, SetupDiGetDeviceInstanceId, SetupDiGetDeviceInterfaceAlias, SetupDiGetDeviceInterfaceDetail, SetupDiGetDeviceInterfacePropertyKeys, SetupDiGetDeviceInterfacePropertyW, SetupDiGetDevicePropertyKeys, SetupDiGetDevicePropertyW, SetupDiGetDeviceRegistryProperty, SetupDiGetDriverInfoDetail, SetupDiGetDriverInstallParams, SetupDiGetHwProfileFriendlyName, SetupDiGetHwProfileFriendlyNameEx, SetupDiGetHwProfileList, SetupDiGetHwProfileListEx, SetupDiGetINFClass, SetupDiGetSelectedDevice, SetupDiGetSelectedDriver, SetupDiGetWizardPage, SetupDiInstallClass, SetupDiInstallClassEx, SetupDiInstallDevice, SetupDiInstallDeviceInterfaces, SetupDiInstallDriverFiles, SetupDiLoadClassIcon, SetupDiLoadDeviceIcon, SetupDiMoveDuplicateDevice, SetupDiOpenClassRegKey, SetupDiOpenClassRegKeyEx, SetupDiOpenDeviceInfo, SetupDiOpenDeviceInterface, SetupDiOpenDeviceInterfaceRegKey, SetupDiOpenDevRegKey, SetupDiRegisterCoDeviceInstallers, SetupDiRegisterDeviceInfo, SetupDiRemoveDevice, SetupDiRemoveDeviceInterface, SetupDiReportAdditionalSoftwareRequested, SetupDiReportDeviceInstallError, SetupDiReportDriverNotFoundError, SetupDiReportDriverPackageImportationError, SetupDiReportGenericDriverInstalled, SetupDiReportPnPDeviceProblem, SetupDiRestartDevices, SetupDiSelectBestCompatDrv, SetupDiSelectDevice, SetupDiSelectOEMDrv, SetupDiSetClassInstallParams, SetupDiSetClassPropertyExW, SetupDiSetClassPropertyW, SetupDiSetClassRegistryProperty, SetupDiSetDeviceInstallParams, SetupDiSetDeviceInterfaceDefault, SetupDiSetDeviceInterfacePropertyW, SetupDiSetDevicePropertyW, SetupDiSetDeviceRegistryProperty, SetupDiSetDriverInstallParams, SetupDiSetSelectedDevice, SetupDiSetSelectedDriver, SetupDiUnremoveDevice, SetupDuplicateDiskSpaceList, SetupEnumInfSections, SetupEnumPublishedInf, SetupFindFirstLine, SetupFindNextLine, SetupFindNextMatchLine, SetupFreeSourceList, SetupGetBackupInformation, SetupGetBinaryField, SetupGetFieldCount, SetupGetFileCompressionInfo, SetupGetFileCompressionInfoEx, SetupGetFileQueueCount, SetupGetFileQueueFlags, SetupGetInfDriverStoreLocation, SetupGetInfFileList, SetupGetInfInformation, SetupGetInfPublishedName, SetupGetInfSections, SetupGetIntField, SetupGetLineByIndex, SetupGetLineCount, SetupGetLineText, SetupGetMultiSzField, SetupGetNonInteractiveMode, SetupGetSourceFileLocation, SetupGetSourceFileSize, SetupGetSourceInfo, SetupGetStringField, SetupGetTargetPath, SetupGetThreadLogToken, SetupInitDefaultQueueCallback, SetupInitDefaultQueueCallbackEx, SetupInitializeFileLog, SetupInstallFile, SetupInstallFileEx, SetupInstallFilesFromInfSection, SetupInstallFromInfSection, SetupInstallLogCloseEventGroup, SetupInstallLogCreateEventGroup, SetupInstallServicesFromInfSection, SetupInstallServicesFromInfSectionEx, SetupIterateCabinet, SetupLogError, SetupLogFile, SetupOpenAppendInfFile, SetupOpenFileQueue, SetupOpenInfFile, SetupOpenLog, SetupOpenMasterInf, SetupPrepareQueueForRestore, SetupPromptForDisk, SetupPromptReboot, SetupQueryDrivesInDiskSpaceList, SetupQueryFileLog, SetupQueryInfFileInformation, SetupQueryInfOriginalFileInformation, SetupQueryInfVersionInformation, SetupQuerySourceList, SetupQuerySpaceRequiredOnDrive, SetupQueueCopy, SetupQueueCopyIndirect, SetupQueueCopySection, SetupQueueDefaultCopy, SetupQueueDelete, SetupQueueDeleteSection, SetupQueueRename, SetupQueueRenameSection, SetupRemoveFileLogEntry, SetupRemoveFromDiskSpaceList, SetupRemoveFromSourceList, SetupRemoveInstallSectionFromDiskSpaceList, SetupRemoveSectionFromDiskSpaceList, SetupRenameError, SetupScanFileQueue, SetupSetDirectoryId, SetupSetDirectoryIdEx, SetupSetFileQueueAlternatePlatform, SetupSetFileQueueFlags, SetupSetNonInteractiveMode, SetupSetPlatformPathOverride, SetupSetSourceList, SetupSetThreadLogToken, SetupTermDefaultQueueCallback, SetupTerminateFileLog, SetupUninstallNewlyCopiedInfs, SetupUninstallOEMInf, SetupVerifyInfFile, SetupWriteTextLog, SetupWriteTextLogError, SetupWriteTextLogInfLine, VerifyCatalogFile
Structures
CABINET_INFO, DEVPROPKEY, FILE_IN_CABINET_INFO, FILEPATHS, FILEPATHS_SIGNERINFO, HDEVINFO, HDSKSPC, HINF, HSPFILEQ, INFCONTEXT, SOURCE_MEDIA, SP_ALTPLATFORM_INFO_V1, SP_ALTPLATFORM_INFO_V2, SP_ALTPLATFORM_INFO_V3, SP_CLASSIMAGELIST_DATA, SP_CLASSINSTALL_HEADER, SP_DETECTDEVICE_PARAMS, SP_DEVICE_INTERFACE_DATA, SP_DEVICE_INTERFACE_DETAIL_DATA, SP_DEVINFO_DATA, SP_DEVINFO_LIST_DETAIL_DATA, SP_DEVINSTALL_PARAMS, SP_DRVINFO_DATA_V2, SP_DRVINFO_DETAIL_DATA, SP_DRVINSTALL_PARAMS, SP_FILE_COPY_PARAMS, SP_INF_INFORMATION, SP_INF_SIGNER_INFO_V1, SP_INF_SIGNER_INFO_V2, SP_NEWDEVICEWIZARD_DATA, SP_ORIGINAL_FILE_INFO, SP_POWERMESSAGEWAKE_PARAMS, SP_PROPCHANGE_PARAMS, SP_PROPSHEETPAGE_REQUEST, SP_REGISTER_CONTROL_STATUS, SP_REMOVEDEVICE_PARAMS, SP_SELECTDEVICE_PARAMS, SP_TROUBLESHOOTER_PARAMS, SP_UNREMOVEDEVICE_PARAMS
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
true