using System.Collections.Generic;
using System.Linq;
using static Vanara.PInvoke.SetupAPI;
namespace Vanara.PInvoke;
/// Items from the CfgMgr32.dll
public static partial class CfgMgr32
{
/// CONFLICT_DETAILS.CD_ulFlags values.
[PInvokeData("cfgmgr32.h", MSDNShortId = "NS:cfgmgr32._CONFLICT_DETAILS_A")]
[Flags]
public enum CM_CDFLAGS : uint
{
///
/// If set, the string contained in the CD_szDescription member represents a driver name instead of a device name, and
/// CD_dnDevInst is -1.
///
CM_CDFLAGS_DRIVER = 0x00000001,
/// If set, the conflicting resources are owned by the root device (that is, the HAL), and CD_dnDevInst is -1.
CM_CDFLAGS_ROOT_OWNED = 0x00000002,
/// If set, the owner of the conflicting resources cannot be determined, and CD_dnDevInst is -1.
CM_CDFLAGS_RESERVED = 0x00000004,
}
/// CONFLICT_DETAILS.CD_ulMask values.
[PInvokeData("cfgmgr32.h", MSDNShortId = "NS:cfgmgr32._CONFLICT_DETAILS_A")]
[Flags]
public enum CM_CDMASK : uint
{
/// If set, CM_Get_Resource_Conflict_Details supplies a value for the CD_dnDevInst member.
CM_CDMASK_DEVINST = 0x00000001,
/// Not used.
CM_CDMASK_RESDES = 0x00000002,
/// If set, CM_Get_Resource_Conflict_Details supplies a value for the CD_ulFlags member.
CM_CDMASK_FLAGS = 0x00000004,
/// If set, CM_Get_Resource_Conflict_Details supplies a value for the CD_szDescription member.
CM_CDMASK_DESCRIPTION = 0x00000008,
}
/// Identifies the device property to be obtained from the registry.
[PInvokeData("cfgmgr32.h")]
public enum CM_DRP
{
/// DeviceDesc REG_SZ property (RW)
CM_DRP_DEVICEDESC = 0x00000001,
/// HardwareID REG_MULTI_SZ property (RW)
CM_DRP_HARDWAREID = 0x00000002,
/// CompatibleIDs REG_MULTI_SZ property (RW)
CM_DRP_COMPATIBLEIDS = 0x00000003,
/// unused
CM_DRP_UNUSED0 = 0x00000004,
/// Service REG_SZ property (RW)
CM_DRP_SERVICE = 0x00000005,
/// unused
CM_DRP_UNUSED1 = 0x00000006,
/// unused
CM_DRP_UNUSED2 = 0x00000007,
/// Class REG_SZ property (RW)
CM_DRP_CLASS = 0x00000008,
/// ClassGUID REG_SZ property (RW)
CM_DRP_CLASSGUID = 0x00000009,
/// Driver REG_SZ property (RW)
CM_DRP_DRIVER = 0x0000000A,
/// ConfigFlags REG_DWORD property (RW)
CM_DRP_CONFIGFLAGS = 0x0000000B,
/// Mfg REG_SZ property (RW)
CM_DRP_MFG = 0x0000000C,
/// FriendlyName REG_SZ property (RW)
CM_DRP_FRIENDLYNAME = 0x0000000D,
/// LocationInformation REG_SZ property (RW)
CM_DRP_LOCATION_INFORMATION = 0x0000000E,
/// PhysicalDeviceObjectName REG_SZ property (R)
CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000F,
/// Capabilities REG_DWORD property (R)
CM_DRP_CAPABILITIES = 0x00000010,
/// UiNumber REG_DWORD property (R)
CM_DRP_UI_NUMBER = 0x00000011,
/// UpperFilters REG_MULTI_SZ property (RW)
CM_DRP_UPPERFILTERS = 0x00000012,
/// LowerFilters REG_MULTI_SZ property (RW)
CM_DRP_LOWERFILTERS = 0x00000013,
/// Bus Type Guid, GUID, (R)
CM_DRP_BUSTYPEGUID = 0x00000014,
/// Legacy bus type, INTERFACE_TYPE, (R)
CM_DRP_LEGACYBUSTYPE = 0x00000015,
/// Bus Number, DWORD, (R)
CM_DRP_BUSNUMBER = 0x00000016,
/// Enumerator Name REG_SZ property (R)
CM_DRP_ENUMERATOR_NAME = 0x00000017,
/// Security - Device override (RW)
CM_DRP_SECURITY = 0x00000018,
/// Security - Device override (RW)
CM_DRP_SECURITY_SDS = 0x00000019,
/// Device Type - Device override (RW)
CM_DRP_DEVTYPE = 0x0000001A,
/// Exclusivity - Device override (RW)
CM_DRP_EXCLUSIVE = 0x0000001B,
/// Characteristics - Device Override (RW)
CM_DRP_CHARACTERISTICS = 0x0000001C,
/// Device Address (R)
CM_DRP_ADDRESS = 0x0000001D,
/// UINumberDescFormat REG_SZ property (RW)
CM_DRP_UI_NUMBER_DESC_FORMAT = 0x0000001E,
/// CM_POWER_DATA REG_BINARY property (R)
CM_DRP_DEVICE_POWER_DATA = 0x0000001F,
/// CM_DEVICE_REMOVAL_POLICY REG_DWORD (R)
CM_DRP_REMOVAL_POLICY = 0x00000020,
/// CM_DRP_REMOVAL_POLICY_HW_DEFAULT REG_DWORD (R)
CM_DRP_REMOVAL_POLICY_HW_DEFAULT = 0x00000021,
/// CM_DRP_REMOVAL_POLICY_OVERRIDE REG_DWORD (RW)
CM_DRP_REMOVAL_POLICY_OVERRIDE = 0x00000022,
/// CM_DRP_INSTALL_STATE REG_DWORD (R)
CM_DRP_INSTALL_STATE = 0x00000023,
/// CM_DRP_LOCATION_PATHS REG_MULTI_SZ (R)
CM_DRP_LOCATION_PATHS = 0x00000024,
/// Base ContainerID REG_SZ property (R)
CM_DRP_BASE_CONTAINERID = 0x00000025,
}
/// Flags for CM_Get_Device_Interface_List_Size.
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_List_SizeW")]
public enum CM_GET_DEVICE_INTERFACE_LIST
{
///
/// The function provides the size of a list containing device interfaces associated with devices that are currently active, and
/// which match the specified GUID and device instance ID, if any.
///
CM_GET_DEVICE_INTERFACE_LIST_PRESENT = 0x00000000,
///
/// The function provides the size of a list that contains device interfaces associated with all devices that match the
/// specified GUID and device instance ID, if any.
///
CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES = 0x00000001,
}
/// Device problem.
[PInvokeData("cfg.h")]
public enum CM_PROB
{
/// no config for device
CM_PROB_NOT_CONFIGURED = 0x00000001,
/// service load failed
CM_PROB_DEVLOADER_FAILED = 0x00000002,
/// out of memory
CM_PROB_OUT_OF_MEMORY = 0x00000003,
///
CM_PROB_ENTRY_IS_WRONG_TYPE = 0x00000004,
///
CM_PROB_LACKED_ARBITRATOR = 0x00000005,
/// boot config conflict
CM_PROB_BOOT_CONFIG_CONFLICT = 0x00000006,
///
CM_PROB_FAILED_FILTER = 0x00000007,
/// Devloader not found
CM_PROB_DEVLOADER_NOT_FOUND = 0x00000008,
/// Invalid ID
CM_PROB_INVALID_DATA = 0x00000009,
///
CM_PROB_FAILED_START = 0x0000000A,
///
CM_PROB_LIAR = 0x0000000B,
/// config conflict
CM_PROB_NORMAL_CONFLICT = 0x0000000C,
///
CM_PROB_NOT_VERIFIED = 0x0000000D,
/// requires restart
CM_PROB_NEED_RESTART = 0x0000000E,
///
CM_PROB_REENUMERATION = 0x0000000F,
///
CM_PROB_PARTIAL_LOG_CONF = 0x00000010,
/// unknown res type
CM_PROB_UNKNOWN_RESOURCE = 0x00000011,
///
CM_PROB_REINSTALL = 0x00000012,
///
CM_PROB_REGISTRY = 0x00000013,
/// WINDOWS 95 ONLY
CM_PROB_VXDLDR = 0x00000014,
/// devinst will remove
CM_PROB_WILL_BE_REMOVED = 0x00000015,
/// devinst is disabled
CM_PROB_DISABLED = 0x00000016,
/// Devloader not ready
CM_PROB_DEVLOADER_NOT_READY = 0x00000017,
/// device doesn't exist
CM_PROB_DEVICE_NOT_THERE = 0x00000018,
///
CM_PROB_MOVED = 0x00000019,
///
CM_PROB_TOO_EARLY = 0x0000001A,
/// no valid log config
CM_PROB_NO_VALID_LOG_CONF = 0x0000001B,
/// install failed
CM_PROB_FAILED_INSTALL = 0x0000001C,
/// device disabled
CM_PROB_HARDWARE_DISABLED = 0x0000001D,
/// can't share IRQ
CM_PROB_CANT_SHARE_IRQ = 0x0000001E,
/// driver failed add
CM_PROB_FAILED_ADD = 0x0000001F,
/// service's Start = 4
CM_PROB_DISABLED_SERVICE = 0x00000020,
/// resource translation failed
CM_PROB_TRANSLATION_FAILED = 0x00000021,
/// no soft config
CM_PROB_NO_SOFTCONFIG = 0x00000022,
/// device missing in BIOS table
CM_PROB_BIOS_TABLE = 0x00000023,
/// IRQ translator failed
CM_PROB_IRQ_TRANSLATION_FAILED = 0x00000024,
/// DriverEntry() failed.
CM_PROB_FAILED_DRIVER_ENTRY = 0x00000025,
/// Driver should have unloaded.
CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD = 0x00000026,
/// Driver load unsuccessful.
CM_PROB_DRIVER_FAILED_LOAD = 0x00000027,
/// Error accessing driver's service key
CM_PROB_DRIVER_SERVICE_KEY_INVALID = 0x00000028,
/// Loaded legacy service created no devices
CM_PROB_LEGACY_SERVICE_NO_DEVICES = 0x00000029,
/// Two devices were discovered with the same name
CM_PROB_DUPLICATE_DEVICE = 0x0000002A,
/// The drivers set the device state to failed
CM_PROB_FAILED_POST_START = 0x0000002B,
/// This device was failed post start via usermode
CM_PROB_HALTED = 0x0000002C,
/// The devinst currently exists only in the registry
CM_PROB_PHANTOM = 0x0000002D,
/// The system is shutting down
CM_PROB_SYSTEM_SHUTDOWN = 0x0000002E,
/// The device is offline awaiting removal
CM_PROB_HELD_FOR_EJECT = 0x0000002F,
/// One or more drivers is blocked from loading
CM_PROB_DRIVER_BLOCKED = 0x00000030,
/// System hive has grown too large
CM_PROB_REGISTRY_TOO_LARGE = 0x00000031,
/// Failed to apply one or more registry properties
CM_PROB_SETPROPERTIES_FAILED = 0x00000032,
/// Device is stalled waiting on a dependency to start
CM_PROB_WAITING_ON_DEPENDENCY = 0x00000033,
/// Failed load driver due to unsigned image.
CM_PROB_UNSIGNED_DRIVER = 0x00000034,
/// Device is being used by kernel debugger
CM_PROB_USED_BY_DEBUGGER = 0x00000035,
/// Device is being reset
CM_PROB_DEVICE_RESET = 0x00000036,
/// Device is blocked while console is locked
CM_PROB_CONSOLE_LOCKED = 0x00000037,
/// Device needs extended class configuration to start
CM_PROB_NEED_CLASS_CONFIG = 0x00000038,
/// Assignment to guest partition failed
CM_PROB_GUEST_ASSIGNMENT_FAILED = 0x00000039,
}
/// Configuration flags
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_HW_Prof_FlagsA")]
[Flags]
public enum CSCONFIGFLAG
{
/// The device instance is disabled in the specified hardware profile.
CSCONFIGFLAG_DISABLED = 1,
/// The hardware profile does not support the specified device instance.
CSCONFIGFLAG_DO_NOT_CREATE = 2,
/// The device cannot be started in the specified hardware profile.
CSCONFIGFLAG_DO_NOT_START = 4,
}
///
/// The CM_Get_Device_ID_List_Size function retrieves the buffer size required to hold a list of device instance IDs for the
/// local machine's device instances.
///
/// Receives a value representing the required buffer size, in characters.
///
/// Caller-supplied pointer to a character string specifying a subset of the machine's device instance identifiers, or NULL.
/// See the following description of ulFlags.
///
///
/// One of the optional, caller-supplied bit flags that specify search filters. If no flags are specified, the function supplies the
/// buffer size required to hold all instance identifiers for all device instances. For a list of bit flags, see the ulFlags
/// description for CM_Get_Device_ID_List.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// The CM_Get_Device_ID_List_Size function should be called to determine the buffer size required by CM_Get_Device_ID_List.
///
/// The size value supplied in the location pointed to by pulLen is guaranteed to represent a buffer size large enough to hold all
/// device instance identifier strings and terminating NULLs. The supplied value might actually represent a buffer size that is
/// larger than necessary, so don't assume the value represents the true length of the character strings that CM_Get_Device_ID_List
/// will provide.
///
/// For information about device instance IDs, see Device Identification Strings.
///
/// Note
///
/// The cfgmgr32.h header defines CM_Get_Device_ID_List_Size as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_id_list_sizea CMAPI CONFIGRET
// CM_Get_Device_ID_List_SizeA( PULONG pulLen, PCSTR pszFilter, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_ID_List_SizeA")]
public static extern CONFIGRET CM_Get_Device_ID_List_Size(out uint pulLen, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? pszFilter, CM_GETIDLIST ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Device_ID_List_Size instead.]
///
///
/// The CM_Get_Device_ID_List_Size_Ex function retrieves the buffer size required to hold a list of device instance IDs for a
/// local or a remote machine's device instances.
///
///
/// Receives a value representing the required buffer size, in characters.
///
/// Caller-supplied pointer to a character string specifying a subset of the machine's device instance identifiers, or NULL.
/// See the following description of ulFlags.
///
///
/// One of the optional, caller-supplied bit flags that specify search filters. If no flags are specified, the function supplies the
/// buffer size required to hold all instance identifiers for all device instances. For a list of bit flags, see the ulFlags
/// description for CM_Get_Device_ID_List_Ex.
///
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// The CM_Get_Device_ID_List_Size_Ex function should be called to determine the buffer size required by CM_Get_Device_ID_List_Ex.
///
/// The size value supplied in the location pointed to by pulLen is guaranteed to represent a buffer size large enough to hold all
/// device instance identifier strings and terminating NULLs. The supplied value might actually represent a buffer size that is
/// larger than necessary, so don't assume the value represents the true length of the character strings that
/// CM_Get_Device_ID_List_Ex will provide.
///
/// For information about device instance IDs, see Device Identification Strings.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_id_list_size_exw CMAPI CONFIGRET
// CM_Get_Device_ID_List_Size_ExW( PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_ID_List_Size_ExW")]
public static extern CONFIGRET CM_Get_Device_ID_List_Size_Ex(out uint pulLen, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? pszFilter, [In, Optional] CM_GETIDLIST ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Device_ID_Size function retrieves the buffer size required to hold a device instance ID for a device instance
/// on the local machine.
///
/// Receives a value representing the required buffer size, in characters.
/// Caller-supplied device instance handle that is bound to the local machine.
/// Not used, must be zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// The CM_Get_Device_ID_Size function should be called to determine the buffer size required by CM_Get_Device_ID.
///
/// The size value supplied in the location pointed to by pulLen is less than MAX_DEVICE_ID_LEN, and does not include the identifier
/// string's terminating NULL. If the specified device instance does not exist, the function supplies a size value of zero.
///
/// For information about device instance IDs, see Device Identification Strings.
/// For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_id_size CMAPI CONFIGRET
// CM_Get_Device_ID_Size( PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_ID_Size")]
public static extern CONFIGRET CM_Get_Device_ID_Size(out uint pulLen, uint dnDevInst, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Device_ID_Size instead.]
///
///
/// The CM_Get_Device_ID_Size_Ex function retrieves the buffer size required to hold a device instance ID for a device
/// instance on a local or a remote machine.
///
///
/// Receives a value representing the required buffer size, in characters.
/// Caller-supplied device instance handle that is bound to the local machine.
/// Not used, must be zero.
///
/// Caller-supplied machine handle to which the caller-supplied device instance handle is bound.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// The CM_Get_Device_ID_Size_Ex function should be called to determine the buffer size required by CM_Get_Device_ID_Ex.
///
/// The size value supplied in the location pointed to by pulLen is less than MAX_DEVICE_ID_LEN, and does not include the identifier
/// string's terminating NULL. If the specified device instance does not exist, the function supplies a size value of zero.
///
/// For information about device instance IDs, see Device Identification Strings.
/// For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_id_size_ex CMAPI CONFIGRET
// CM_Get_Device_ID_Size_Ex( PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_ID_Size_Ex")]
public static extern CONFIGRET CM_Get_Device_ID_Size_Ex(out uint pulLen, uint dnDevInst, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Device_ID function retrieves the device instance ID for a specified device instance on the local machine.
///
/// Caller-supplied device instance handle that is bound to the local machine.
///
/// Address of a buffer to receive a device instance ID string. The required buffer size can be obtained by calling
/// CM_Get_Device_ID_Size, then incrementing the received value to allow room for the string's terminating NULL.
///
/// Caller-supplied length, in characters, of the buffer specified by Buffer.
/// Not used, must be zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
///
/// The function appends a NULL terminator to the supplied device instance ID string, unless the buffer is too small to hold the
/// string. In this case, the function supplies as much of the identifier string as will fit into the buffer, and then returns CR_BUFFER_SMALL.
///
/// For information about device instance IDs, see Device Identification Strings.
/// For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_idw CMAPI CONFIGRET CM_Get_Device_IDW(
// DEVINST dnDevInst, PWSTR Buffer, ULONG BufferLen, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_IDW")]
public static extern CONFIGRET CM_Get_Device_ID(uint dnDevInst, StringBuilder Buffer, uint BufferLen, uint ulFlags = 0);
///
/// The CM_Get_Device_Interface_Alias function returns the alias of the specified device interface instance, if the alias exists.
///
///
/// Pointer to the name of the device interface instance for which to retrieve an alias. The caller typically received this string
/// from a call to CM_Get_Device_Interface_List, or in a PnP notification structure.
///
/// Pointer to a GUID specifying the interface class of the alias to retrieve.
///
///
/// Specifies a pointer to a buffer, that upon successful return, points to a string containing the name of the alias. The caller
/// must free this string when it is no longer needed.
///
/// A buffer is required. Otherwise, the call will fail.
///
///
///
/// Supplies the count of characters in pszAliasDeviceInterface and receives the number of characters required to hold the alias
/// device interface.
///
/// On input, this parameter must be greater than 0.
///
/// Reserved. Do not use.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
///
/// Return code
/// Description
///
/// -
/// CR_NO_SUCH_DEVICE_INTERFACE
/// Possibly indicates that there is no alias of the specified interface class.
///
/// -
/// CR_OUT_OF_MEMORY
/// There is not enough memory to complete the operation.
///
/// -
/// CR_BUFFER_SMALL
/// The buffer passed is too small.
///
///
///
///
///
/// Device interfaces are considered aliases if they are exposed by the same underlying device and have identical interface
/// reference strings, but are of different interface classes.
///
///
/// The pszDeviceInterface parameter specifies a device interface instance for a particular device, belonging to a particular
/// interface class, with a particular reference string. CM_Get_Device_Interface_Alias returns another device interface
/// instance for the same device and reference string, but of a different interface class, if it exists.
///
///
/// For example, the function driver for a fault-tolerant volume could register and set two device interfaces, one of the
/// fault-tolerant-volume interface class and one of the volume interface class. Another driver could call
/// CM_Get_Device_Interface_Alias with the symbolic link for one of the interfaces and ask whether the other interface exists
/// by specifying its interface class.
///
///
/// Two device interfaces with NULL reference strings are aliases if they are exposed by the same underlying device and have
/// different interface class GUIDs.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_aliasw CMAPI CONFIGRET
// CM_Get_Device_Interface_AliasW( LPCWSTR pszDeviceInterface, LPGUID AliasInterfaceGuid, LPWSTR pszAliasDeviceInterface, PULONG
// pulLength, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_AliasW")]
public static extern CONFIGRET CM_Get_Device_Interface_Alias([MarshalAs(UnmanagedType.LPTStr)] string pszDeviceInterface, in Guid AliasInterfaceGuid,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszAliasDeviceInterface, ref uint pulLength, uint ulFlags = 0);
///
/// The CM_Get_Device_Interface_List function retrieves a list of device interface instances that belong to a specified
/// device interface class.
///
/// Supplies a GUID that identifies a device interface class.
///
/// Caller-supplied pointer to a NULL-terminated string that represents a device instance ID. If specified, the function retrieves
/// device interfaces that are supported by the device for the specified class. If this value is NULL, or if it points to a
/// zero-length string, the function retrieves all interfaces that belong to the specified class.
///
///
/// Caller-supplied pointer to a buffer that receives multiple, NULL-terminated Unicode strings, each representing the symbolic link
/// name of an interface instance.
///
///
/// Caller-supplied value that specifies the length, in characters, of the buffer pointed to by Buffer. Call
/// CM_Get_Device_Interface_List_Size to determine the required buffer size.
///
///
/// Contains one of the following caller-supplied flags:
/// CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES
///
/// The function provides a list containing device interfaces associated with all devices that match the specified GUID and device
/// instance ID, if any.
///
/// CM_GET_DEVICE_INTERFACE_LIST_PRESENT
///
/// The function provides a list containing device interfaces associated with devices that are currently active, and which match the
/// specified GUID and device instance ID, if any.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the error codes with the CR_ prefix as
/// defined in Cfgmgr32.h.
///
/// The following table includes some of the more common error codes that this function might return.
///
///
/// Return code
/// Description
///
/// -
/// CR_BUFFER_SMALL
/// The Buffer buffer is too small to hold the requested list of device interfaces.
///
///
///
///
///
/// Between calling CM_Get_Device_Interface_List_Size to get the size of the list and calling CM_Get_Device_Interface_List to
/// get the list, a new device interface can be added to the system causing the size returned to no longer be valid. Callers should
/// be robust to that condition and retry getting the size and the list if CM_Get_Device_Interface_List returns CR_BUFFER_SMALL.
///
/// Examples
/// This snippet illustrates retrying getting the size and the list as described in the Remarks section.
///
/// CONFIGRET cr = CR_SUCCESS; PWSTR DeviceInterfaceList = NULL; ULONG DeviceInterfaceListLength = 0; do { cr = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, (LPGUID)&GUID_DEVINTERFACE_VOLUME, NULL, CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES); if (cr != CR_SUCCESS) { break; } if (DeviceInterfaceList != NULL) { HeapFree(GetProcessHeap(), 0, DeviceInterfaceList); } DeviceInterfaceList = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DeviceInterfaceListLength * sizeof(WCHAR)); if (DeviceInterfaceList == NULL) { cr = CR_OUT_OF_MEMORY; break; } cr = CM_Get_Device_Interface_List((LPGUID)&GUID_DEVINTERFACE_VOLUME, NULL, DeviceInterfaceList, DeviceInterfaceListLength, CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES); } while (cr == CR_BUFFER_SMALL); if (cr != CR_SUCCESS) { goto Exit; }
///
///
/// Note
///
/// The cfgmgr32.h header defines CM_Get_Device_Interface_List as an alias which automatically selects the ANSI or Unicode version
/// of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
/// code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_lista CMAPI CONFIGRET
// CM_Get_Device_Interface_ListA( LPGUID InterfaceClassGuid, DEVINSTID_A pDeviceID, PZZSTR Buffer, ULONG BufferLen, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_ListA")]
public static extern CONFIGRET CM_Get_Device_Interface_List(in Guid InterfaceClassGuid, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? pDeviceID,
IntPtr Buffer, uint BufferLen, CM_GET_DEVICE_INTERFACE_LIST ulFlags);
///
/// The CM_Get_Device_Interface_List function retrieves a list of device interface instances that belong to a specified
/// device interface class.
///
/// Supplies a GUID that identifies a device interface class.
///
/// Contains one of the following caller-supplied flags:
/// CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES
///
/// The function provides a list containing device interfaces associated with all devices that match the specified GUID and device
/// instance ID, if any.
///
/// CM_GET_DEVICE_INTERFACE_LIST_PRESENT
///
/// The function provides a list containing device interfaces associated with devices that are currently active, and which match the
/// specified GUID and device instance ID, if any.
///
///
///
/// Caller-supplied string that represents a device instance ID. If specified, the function retrieves device interfaces that are
/// supported by the device for the specified class. If this value is , or if it is a zero-length string, the
/// function retrieves all interfaces that belong to the specified class.
///
/// An array of strings, each representing the symbolic link name of an interface instance.
public static string[] CM_Get_Device_Interface_List(in Guid InterfaceClassGuid, CM_GET_DEVICE_INTERFACE_LIST ulFlags, string? pDeviceID = null)
{
while (true)
{
CM_Get_Device_Interface_List_Size(out var len, InterfaceClassGuid, pDeviceID, ulFlags).ThrowIfFailed();
using var mem = new SafeCoTaskMemHandle(len * StringHelper.GetCharSize());
var ret = CM_Get_Device_Interface_List(InterfaceClassGuid, pDeviceID, mem, len, ulFlags);
if (ret == CONFIGRET.CR_SUCCESS)
return mem.ToStringEnum().ToArray();
else if (ret != CONFIGRET.CR_BUFFER_SMALL)
ret.ThrowIfFailed();
}
}
///
/// The CM_Get_Device_Interface_List_Size function retrieves the buffer size that must be passed to the
/// CM_Get_Device_Interface_List function.
///
///
/// Caller-supplied pointer to a location that receives the required length, in characters, of a buffer to hold the multiple Unicode
/// strings that will be returned by CM_Get_Device_Interface_List.
///
/// Supplies a GUID that identifies a device interface class.
///
/// Caller-supplied pointer to a NULL-terminated string that represents a device instance ID. If specified, the function retrieves
/// the length of symbolic link names for the device interfaces that are supported by the device, for the specified class. If this
/// value is NULL, or if it points to a zero-length string, the function retrieves the length of symbolic link names for all
/// interfaces that belong to the specified class.
///
///
/// Contains one of the following caller-supplied flags:
///
///
/// Value
/// Meaning
///
/// -
/// CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES
///
/// The function provides the size of a list that contains device interfaces associated with all devices that match the specified
/// GUID and device instance ID, if any.
///
///
/// -
/// CM_GET_DEVICE_INTERFACE_LIST_PRESENT
///
/// The function provides the size of a list containing device interfaces associated with devices that are currently active, and
/// which match the specified GUID and device instance ID, if any.
///
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the error codes with the
/// CR_ prefix as defined in Cfgmgr32.h.
///
///
/// Note
///
/// The cfgmgr32.h header defines CM_Get_Device_Interface_List_Size as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_list_sizew CMAPI CONFIGRET
// CM_Get_Device_Interface_List_SizeW( PULONG pulLen, LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_List_SizeW")]
public static extern CONFIGRET CM_Get_Device_Interface_List_Size(out uint pulLen, in Guid InterfaceClassGuid,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string? pDeviceID, CM_GET_DEVICE_INTERFACE_LIST ulFlags);
/// The CM_Get_Device_Interface_Property function retrieves a device property that is set for a device interface.
///
/// Pointer to a string that identifies the device interface instance to retrieve the property from.
///
///
/// Pointer to a DEVPROPKEY structure that represents the device interface property key of the device interface property to retrieve.
///
///
/// 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. CM_Get_Device_Interface_Property retrieves
/// the requested property only if the buffer is large enough to hold all the property value data. The pointer can be NULL.
///
///
/// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, *PropertyBufferSize must be set to zero. As
/// output, if the buffer is not large enough to hold all the property value data, CM_Get_Device_Interface_Property returns
/// the size of the data, in bytes, in *PropertyBufferSize.
///
/// Reserved. Must be set to zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_Device_Interface_Property is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_propertyw CMAPI CONFIGRET
// CM_Get_Device_Interface_PropertyW( LPCWSTR pszDeviceInterface, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE
// PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_PropertyW")]
public static extern CONFIGRET CM_Get_Device_Interface_Property([MarshalAs(UnmanagedType.LPTStr)] string pszDeviceInterface, in DEVPROPKEY PropertyKey,
out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer, ref uint PropertyBufferSize, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use
/// CM_Get_Device_Interface_Property instead.]
///
/// The CM_Get_Device_Interface_Property_ExW function retrieves a device property that is set for a device interface.
///
///
/// Pointer to a string that identifies the device interface instance to retrieve the property from.
///
///
/// Pointer to a DEVPROPKEY structure that represents the device interface property key of the device interface property to retrieve.
///
///
/// 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. CM_Get_Device_Interface_Property_ExW
/// retrieves the requested property only if the buffer is large enough to hold all the property value data. The pointer can be NULL.
///
///
/// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, *PropertyBufferSize must be set to zero. As
/// output, if the buffer is not large enough to hold all the property value data, CM_Get_Device_Interface_Property_ExW
/// returns the size of the data, in bytes, in *PropertyBufferSize.
///
/// Reserved. Must be set to zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_Device_Interface_Property_ExW is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_property_exw CMAPI CONFIGRET
// CM_Get_Device_Interface_Property_ExW( LPCWSTR pszDeviceInterface, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE
// PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_Property_ExW")]
public static extern CONFIGRET CM_Get_Device_Interface_Property_Ex([MarshalAs(UnmanagedType.LPTStr)] string pszDeviceInterface, in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType,
[Out, Optional] IntPtr PropertyBuffer, ref uint PropertyBufferSize, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Device_Interface_Property_Keys function retrieves an array of device property keys that represent the device
/// properties that are set for a device interface.
///
///
/// Pointer to a string that identifies the device interface instance to retrieve the property keys from.
///
///
/// 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 interface. The pointer is optional and can be NULL
///
///
/// The size, in DEVPROPKEY-typed units, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL, *PropertyKeyCount must
/// be set to zero. As output, if PropertyKeyArray is not large enough to hold all the property key data,
/// CM_Get_Device_Interface_Property_Keys returns the count of the keys, in *PropertyKeyCount.
///
/// Reserved. Must be set to zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_Device_Interface_Property_Keys is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_property_keysw CMAPI CONFIGRET
// CM_Get_Device_Interface_Property_KeysW( LPCWSTR pszDeviceInterface, DEVPROPKEY *PropertyKeyArray, PULONG PropertyKeyCount, ULONG
// ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_Property_KeysW")]
public static extern CONFIGRET CM_Get_Device_Interface_Property_Keys([MarshalAs(UnmanagedType.LPTStr)] string pszDeviceInterface,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[]? PropertyKeyArray, ref uint PropertyKeyCount, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use
/// CM_Get_Device_Interface_Property_Keys instead.]
///
///
/// The CM_Get_Device_Interface_Property_Keys_ExW function retrieves an array of device property keys that represent the
/// device properties that are set for a device interface.
///
///
///
/// Pointer to a string that identifies the device interface instance to retrieve the property keys from.
///
///
/// 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 interface. The pointer is optional and can be NULL
///
///
/// The size, in DEVPROPKEY-typed units, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL, *PropertyKeyCount must
/// be set to zero. As output, if PropertyKeyArray is not large enough to hold all the property key data,
/// CM_Get_Device_Interface_Property_Keys_ExW returns the count of the keys, in *PropertyKeyCount.
///
/// Reserved. Must be set to zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_Device_Interface_Property_Keys_ExW is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_device_interface_property_keys_exw CMAPI CONFIGRET
// CM_Get_Device_Interface_Property_Keys_ExW( LPCWSTR pszDeviceInterface, DEVPROPKEY *PropertyKeyArray, PULONG PropertyKeyCount,
// ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Device_Interface_Property_Keys_ExW")]
public static extern CONFIGRET CM_Get_Device_Interface_Property_Keys_Ex([MarshalAs(UnmanagedType.LPTStr)] string pszDeviceInterface,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[]? PropertyKeyArray, ref uint PropertyKeyCount, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
/// The CM_Get_DevNode_Property function retrieves a device instance property.
/// Device instance handle that is bound to the local machine.
///
/// Pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
///
///
/// 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.
///
///
/// Pointer to a buffer that receives the requested device instance property. CM_Get_DevNode_Property retrieves the requested
/// property only if the buffer is large enough to hold all the property value data. The pointer can be NULL.
///
///
/// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, *PropertyBufferSize must be set to zero. As
/// output, if the buffer is not large enough to hold all the property value data, CM_Get_DevNode_Property returns the size
/// of the data, in bytes, in *PropertyBufferSize.
///
/// Reserved. Must be set to zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_DevNode_Property is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_propertyw CMAPI CONFIGRET
// CM_Get_DevNode_PropertyW( DEVINST dnDevInst, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer,
// PULONG PropertyBufferSize, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_PropertyW")]
public static extern CONFIGRET CM_Get_DevNode_Property(uint dnDevInst, in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer,
ref uint PropertyBufferSize, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_DevNode_Property instead.]
///
/// The CM_Get_DevNode_Property_ExW function retrieves a device instance property.
///
/// Device instance handle that is bound to the local machine.
///
/// Pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
///
///
/// 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.
///
///
/// Pointer to a buffer that receives the requested device instance property. CM_Get_DevNode_Property_ExW retrieves the
/// requested property only if the buffer is large enough to hold all the property value data. The pointer can be NULL.
///
///
/// The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, *PropertyBufferSize must be set to zero. As
/// output, if the buffer is not large enough to hold all the property value data, CM_Get_DevNode_Property_ExW returns the
/// size of the data, in bytes, in *PropertyBufferSize.
///
/// Reserved. Must be set to zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_DevNode_Property_ExW is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_property_exw CMAPI CONFIGRET
// CM_Get_DevNode_Property_ExW( DEVINST dnDevInst, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer,
// PULONG PropertyBufferSize, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Property_ExW")]
public static extern CONFIGRET CM_Get_DevNode_Property_Ex(uint dnDevInst, in DEVPROPKEY PropertyKey, out DEVPROPTYPE PropertyType, [Out, Optional] IntPtr PropertyBuffer,
ref uint PropertyBufferSize, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_DevNode_Property_Keys function retrieves an array of the device property keys that represent the device
/// properties that are set for a device instance.
///
/// Device instance handle that is bound to the local machine.
///
/// 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.
///
///
/// The size, in DEVPROPKEY-typed units, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL, *PropertyKeyCount must
/// be set to zero. As output, If PropertyKeyArray is not large enough to hold all the property key data,
/// CM_Get_DevNode_Property_Keys returns the count of the keys in *PropertyKeyCount.
///
/// Reserved. Must be set to zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_DevNode_Property_Keys is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_property_keys CMAPI CONFIGRET
// CM_Get_DevNode_Property_Keys( DEVINST dnDevInst, DEVPROPKEY *PropertyKeyArray, PULONG PropertyKeyCount, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Property_Keys")]
public static extern CONFIGRET CM_Get_DevNode_Property_Keys(uint dnDevInst, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[]? PropertyKeyArray,
ref uint PropertyKeyCount, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_DevNode_Property_Keys instead.]
///
///
/// The CM_Get_DevNode_Property_Keys_Ex function retrieves an array of the device property keys that represent the device
/// properties that are set for a device instance.
///
///
/// Device instance handle that is bound to the local machine.
///
/// 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.
///
///
/// The size, in DEVPROPKEY-typed units, of the PropertyKeyArray buffer. If PropertyKeyArray is set to NULL, *PropertyKeyCount must
/// be set to zero. As output, If PropertyKeyArray is not large enough to hold all the property key data,
/// CM_Get_DevNode_Property_Keys_Ex returns the count of the keys in *PropertyKeyCount.
///
/// Reserved. Must be set to zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// CM_Get_DevNode_Property_Keys_Ex is part of the Unified Device Property Model.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_property_keys_ex CMAPI CONFIGRET
// CM_Get_DevNode_Property_Keys_Ex( DEVINST dnDevInst, DEVPROPKEY *PropertyKeyArray, PULONG PropertyKeyCount, ULONG ulFlags,
// HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Property_Keys_Ex")]
public static extern CONFIGRET CM_Get_DevNode_Property_Keys_Ex(uint dnDevInst, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] DEVPROPKEY[]? PropertyKeyArray,
ref uint PropertyKeyCount, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
/// The CM_Get_DevNode_Registry_Property function retrieves a specified device property from the registry.
/// A caller-supplied device instance handle that is bound to the local machine.
///
/// A CM_DRP_-prefixed constant value that identifies the device property to be obtained from the registry. These constants are
/// defined in Cfgmgr32.h.
///
///
/// Optional, can be NULL. A pointer to a location that receives the registry data type, specified as a REG_-prefixed
/// constant defined in Winnt.h.
///
///
/// Optional, can be NULL. A pointer to a caller-supplied buffer that receives the requested device property. If this value
/// is NULL, the function supplies only the length of the requested data in the address pointed to by pulLength.
///
///
/// A pointer to a ULONG variable into which the function stores the length, in bytes, of the requested device property.
/// If the Buffer parameter is set to NULL, the ULONG variable must be set to zero.
///
/// If the Buffer parameter is not set to NULL, the ULONG variable must be set to the length, in bytes, of the
/// caller-supplied buffer.
///
///
/// Not used, must be zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes that are
/// defined in Cfgmgr32.h.
///
/// For information about how to use device instance handles that are bound to the local machine, see CM_Get_Child.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_registry_propertyw CMAPI CONFIGRET
// CM_Get_DevNode_Registry_PropertyW( DEVINST dnDevInst, ULONG ulProperty, PULONG pulRegDataType, PVOID Buffer, PULONG pulLength,
// ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Registry_PropertyW")]
public static extern CONFIGRET CM_Get_DevNode_Registry_Property(uint dnDevInst, CM_DRP ulProperty, out REG_VALUE_TYPE pulRegDataType,
[Out, Optional] IntPtr Buffer, ref uint pulLength, uint ulFlags = 0);
///
/// The CM_Get_DevNode_Status function obtains the status of a device instance from its device node (devnode) in the local
/// machine's device tree.
///
///
/// Address of a location to receive status bit flags. The function can set any combination of the DN_- prefixed bit flags
/// defined in Cfg.h.
///
///
/// Address of a location to receive one of the CM_PROB_-prefixed problem values defined in Cfg.h. Used only if
/// DN_HAS_PROBLEM is set in pulStatus.
///
/// Caller-supplied device instance handle that is bound to the local machine.
/// Not used, must be zero.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
/// For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_status CMAPI CONFIGRET
// CM_Get_DevNode_Status( PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Status")]
public static extern CONFIGRET CM_Get_DevNode_Status(out DN pulStatus, out CM_PROB pulProblemNumber, uint dnDevInst, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_DevNode_Status instead.]
///
///
/// The CM_Get_DevNode_Status_Ex function obtains the status of a device instance from its device node (devnode) on a local
/// or a remote machine's device tree.
///
///
///
/// Address of a location to receive status bit flags. The function can set any combination of the DN_-prefixed bit flags defined in Cfg.h.
///
///
/// Address of a location to receive one of the CM_PROB_-prefixed problem values defined in Cfg.h. Used only if DN_HAS_PROBLEM is
/// set in pulStatus.
///
/// Caller-supplied device instance handle that is bound to the machine handle supplied by hMachine.
/// Not used, must be zero.
///
/// Caller-supplied machine handle to which the caller-supplied device instance handle is bound.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_status_ex CMAPI CONFIGRET
// CM_Get_DevNode_Status_Ex( PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_DevNode_Status_Ex")]
public static extern CONFIGRET CM_Get_DevNode_Status_Ex(out DN pulStatus, out CM_PROB pulProblemNumber, uint dnDevInst, [In, Optional] uint ulFlags,
[In, Optional] HMACHINE hMachine);
///
/// The CM_Get_First_Log_Conf function obtains the first logical configuration, of a specified configuration type, associated
/// with a specified device instance on the local machine.
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. See the following Remarks section.
///
/// Caller-supplied device instance handle that is bound to the local machine.
///
///
/// Caller-supplied flag value indicating the type of logical configuration being requested. One of the flags in the following table
/// must be specified.
///
///
///
/// Configuration Type Flags
/// Definitions
///
/// -
/// BASIC_LOG_CONF
/// The caller is requesting basic configuration information.
///
/// -
/// FILTERED_LOG_CONF
/// The caller is requesting filtered configuration information.
///
/// -
/// ALLOC_LOG_CONF
/// The caller is requesting allocated configuration information.
///
/// -
/// BOOT_LOG_CONF
/// The caller is requesting boot configuration information.
///
/// -
/// FORCED_LOG_CONF
/// The caller is requesting forced configuration information.
///
/// -
/// OVERRIDE_LOG_CONF
/// The caller is requesting override configuration information.
///
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_First_Log_Conf returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// Calling CM_Add_Empty_Log_Conf or CM_Free_Log_Conf can invalidate the handle obtained from a previous call to
/// CM_Get_First_Log_Conf. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf or
/// CM_Free_Log_Conf, your code must call CM_Get_First_Log_Conf again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_First_Log_Conf is called with plcLogConf set to NULL, no handle is returned. This allows you to use the
/// return status to determine if a configuration exists without the need to subsequently free the handle.
///
/// For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_first_log_conf CMAPI CONFIGRET
// CM_Get_First_Log_Conf( PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_First_Log_Conf")]
public static extern CONFIGRET CM_Get_First_Log_Conf(out SafeLOG_CONF plcLogConf, uint dnDevInst, LOG_CONF_FLAG ulFlags);
///
/// The CM_Get_First_Log_Conf function obtains the first logical configuration, of a specified configuration type, associated
/// with a specified device instance on the local machine.
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. See the following Remarks section.
///
/// Caller-supplied device instance handle that is bound to the local machine.
///
///
/// Caller-supplied flag value indicating the type of logical configuration being requested. One of the flags in the following table
/// must be specified.
///
///
///
/// Configuration Type Flags
/// Definitions
///
/// -
/// BASIC_LOG_CONF
/// The caller is requesting basic configuration information.
///
/// -
/// FILTERED_LOG_CONF
/// The caller is requesting filtered configuration information.
///
/// -
/// ALLOC_LOG_CONF
/// The caller is requesting allocated configuration information.
///
/// -
/// BOOT_LOG_CONF
/// The caller is requesting boot configuration information.
///
/// -
/// FORCED_LOG_CONF
/// The caller is requesting forced configuration information.
///
/// -
/// OVERRIDE_LOG_CONF
/// The caller is requesting override configuration information.
///
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_First_Log_Conf returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// Calling CM_Add_Empty_Log_Conf or CM_Free_Log_Conf can invalidate the handle obtained from a previous call to
/// CM_Get_First_Log_Conf. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf or
/// CM_Free_Log_Conf, your code must call CM_Get_First_Log_Conf again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_First_Log_Conf is called with plcLogConf set to NULL, no handle is returned. This allows you to use the
/// return status to determine if a configuration exists without the need to subsequently free the handle.
///
/// For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_first_log_conf CMAPI CONFIGRET
// CM_Get_First_Log_Conf( PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_First_Log_Conf")]
public static extern CONFIGRET CM_Get_First_Log_Conf([In, Optional] IntPtr plcLogConf, uint dnDevInst, LOG_CONF_FLAG ulFlags);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_First_Log_Conf instead.]
///
///
/// The CM_Get_First_Log_Conf_Ex function obtains the first logical configuration associated with a specified device instance
/// on a local or a remote machine.
///
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. See the Remarks section.
///
/// Caller-supplied device instance handle that is bound to the machine handle supplied by hMachine.
///
/// Caller-supplied flag value indicating the type of logical configuration being requested. For a list of flags, see the ulFlags
/// description for CM_Get_First_Log_Conf.
///
///
/// Caller-supplied machine handle to which the caller-supplied device instance handle is bound.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_First_Log_Conf_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// Calling CM_Add_Empty_Log_Conf_Ex or CM_Free_Log_Conf_Ex can invalidate the handle obtained from a previous call to
/// CM_Get_First_Log_Conf_Ex. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf_Ex
/// or CM_Free_Log_Conf_Ex, your code must call CM_Get_First_Log_Conf_Ex again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_First_Log_Conf_Ex is called with plcLogConf set to NULL, no handle is returned. This allows you to use
/// the return status to determine if a configuration exists without the need to subsequently free the handle.
///
/// For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_first_log_conf_ex CMAPI CONFIGRET
// CM_Get_First_Log_Conf_Ex( PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_First_Log_Conf_Ex")]
public static extern CONFIGRET CM_Get_First_Log_Conf_Ex(out SafeLOG_CONF plcLogConf, uint dnDevInst, LOG_CONF_FLAG ulFlags, [In, Optional] HMACHINE hMachine);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_First_Log_Conf instead.]
///
///
/// The CM_Get_First_Log_Conf_Ex function obtains the first logical configuration associated with a specified device instance
/// on a local or a remote machine.
///
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. See the Remarks section.
///
/// Caller-supplied device instance handle that is bound to the machine handle supplied by hMachine.
///
/// Caller-supplied flag value indicating the type of logical configuration being requested. For a list of flags, see the ulFlags
/// description for CM_Get_First_Log_Conf.
///
///
/// Caller-supplied machine handle to which the caller-supplied device instance handle is bound.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_First_Log_Conf_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// Calling CM_Add_Empty_Log_Conf_Ex or CM_Free_Log_Conf_Ex can invalidate the handle obtained from a previous call to
/// CM_Get_First_Log_Conf_Ex. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf_Ex
/// or CM_Free_Log_Conf_Ex, your code must call CM_Get_First_Log_Conf_Ex again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_First_Log_Conf_Ex is called with plcLogConf set to NULL, no handle is returned. This allows you to use
/// the return status to determine if a configuration exists without the need to subsequently free the handle.
///
/// For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_first_log_conf_ex CMAPI CONFIGRET
// CM_Get_First_Log_Conf_Ex( PLOG_CONF plcLogConf, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_First_Log_Conf_Ex")]
public static extern CONFIGRET CM_Get_First_Log_Conf_Ex([In, Optional] IntPtr plcLogConf, uint dnDevInst, LOG_CONF_FLAG ulFlags, [In, Optional] HMACHINE hMachine);
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated and should not be used.]
///
/// The CM_Get_HW_Prof_Flags function retrieves the hardware profile-specific configuration flags for a device instance on a
/// local machine.
///
///
///
/// Pointer to a NULL-terminated string that contains the device instance ID of the device for which to retrieve hardware
/// profile-specific configuration flags.
///
///
/// A variable of ULONG type that specifies the identifier of the hardware profile for which to retrieve configuration flags. If
/// this parameter is zero, this function retrieves the configuration flags for the current hardware profile.
///
///
///
/// Pointer to a caller-supplied variable of ULONG type that receives zero or a bitwise OR of the following configuration flags that
/// are defined in Regstr.h:
///
/// CSCONFIGFLAG_BITS
/// Bitwise OR of the other CSCONFIGFLAG_Xxx flags.
/// CSCONFIGFLAG_DISABLE
/// The device instance is disabled in the specified hardware profile.
/// CSCONFIGFLAG_DO_NOT_CREATE
/// The hardware profile does not support the specified device instance.
/// CSCONFIGFLAG_DO_NOT_START
/// The device cannot be started in the specified hardware profile.
///
/// Reserved for internal use. Must be set to zero.
///
/// If the operation succeeds, CM_Get_HW_Prof_Flags returns CR_SUCCESS. Otherwise, the function returns one of the CR_Xxx
/// error codes that are defined in Cfgmgr32.h.
///
///
/// To retrieve a list of hardware profile IDs that are currently defined on a local machine, call SetupDiGetHwProfileList.
/// To retrieve configuration flags for a device instance on a remote machine, call CM_Get_HW_Prof_Flags_Ex.
///
/// Note
///
/// The cfgmgr32.h header defines CM_Get_HW_Prof_Flags as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_hw_prof_flagsa CMAPI CONFIGRET
// CM_Get_HW_Prof_FlagsA( DEVINSTID_A pDeviceID, ULONG ulHardwareProfile, PULONG pulValue, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_HW_Prof_FlagsA")]
public static extern CONFIGRET CM_Get_HW_Prof_Flags([MarshalAs(UnmanagedType.LPTStr)] string pDeviceID, uint ulHardwareProfile, out CSCONFIGFLAG pulValue, uint ulFlags = 0);
///
/// [This function has been deprecated and should not be used.]
///
/// The CM_Get_HW_Prof_Flags_Ex function retrieves the hardware profile-specific configuration flags for a device instance on
/// a remote machine or a local machine.
///
///
///
/// Pointer to a NULL-terminated string that contains the device instance ID of the device for which to retrieve hardware
/// profile-specific configuration flags.
///
///
/// A variable of ULONG type that specifies the identifier of the hardware profile for which to retrieve configuration flags. If
/// this parameter is zero, this function retrieves the configuration flags for the current hardware profile.
///
///
///
/// Pointer to a caller-supplied variable of ULONG type that receives zero or a bitwise OR of the following configuration flags that
/// are defined in Regstr.h:
///
/// CSCONFIGFLAG_BITS
/// Bitwise OR of the other CSCONFIGFLAG_Xxx flags.
/// CSCONFIGFLAG_DISABLE
/// The device instance is disabled in the specified hardware profile.
/// CSCONFIGFLAG_DO_NOT_CREATE
/// The hardware profile does not support the specified device instance.
/// CSCONFIGFLAG_DO_NOT_START
/// The device cannot be started in the specified hardware profile.
///
/// Reserved for internal use. Must be set to zero.
///
///
/// A machine handle that is returned by call to CM_Connect_Machine or NULL. If this parameter is set to NULL,
/// CM_Get_HW_Prof_Flags_Ex retrieves the configuration flags on the local machine.
///
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, CM_Get_HW_Prof_Flags returns CR_SUCCESS. Otherwise, the function returns one of the
/// CR_-prefixed error codes that are defined in Cfgmgr32.h.
///
///
/// To retrieve a list of the hardware profile IDs that are currently defined on a remote machine, call SetupDiGetHwProfileListEx.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
/// Note
///
/// The cfgmgr32.h header defines CM_Get_HW_Prof_Flags_Ex as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_hw_prof_flags_exa CMAPI CONFIGRET
// CM_Get_HW_Prof_Flags_ExA( DEVINSTID_A pDeviceID, ULONG ulHardwareProfile, PULONG pulValue, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_HW_Prof_Flags_ExA")]
public static extern CONFIGRET CM_Get_HW_Prof_Flags_Ex([MarshalAs(UnmanagedType.LPTStr)] string pDeviceID, uint ulHardwareProfile, out CSCONFIGFLAG pulValue,
[In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Log_Conf_List function obtains the logical configurations, of a specified configuration type, associated with
/// a specified device instance on the local machine.
///
/// Caller-supplied device instance handle that is bound to the local machine.
///
///
/// Caller-supplied flag value indicating the type of logical configuration being requested. One of the flags in the following table
/// must be specified.
///
///
///
/// Configuration Type Flags
/// Definitions
///
/// -
/// BASIC_LOG_CONF
/// The caller is requesting basic configuration information.
///
/// -
/// FILTERED_LOG_CONF
/// The caller is requesting filtered configuration information.
///
/// -
/// ALLOC_LOG_CONF
/// The caller is requesting allocated configuration information.
///
/// -
/// BOOT_LOG_CONF
/// The caller is requesting boot configuration information.
///
/// -
/// FORCED_LOG_CONF
/// The caller is requesting forced configuration information.
///
/// -
/// OVERRIDE_LOG_CONF
/// The caller is requesting override configuration information.
///
///
///
///
/// A sequence of safe handles to a logical configurations.
///
/// Note Starting with Windows 8, CM_Get_First_Log_Conf returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_First_Log_Conf")]
public static IEnumerable CM_Get_Log_Conf_List(uint dnDevInst, LOG_CONF_FLAG ulFlags)
{
CONFIGRET ret = CM_Get_First_Log_Conf(out var lc, dnDevInst, ulFlags);
if (ret == CONFIGRET.CR_NO_MORE_LOG_CONF)
yield break;
ret.ThrowIfFailed();
yield return lc;
while ((ret = CM_Get_Next_Log_Conf(out lc, lc)) == CONFIGRET.CR_SUCCESS)
yield return lc;
if (ret != CONFIGRET.CR_NO_MORE_LOG_CONF) ret.ThrowIfFailed();
}
///
/// The CM_Get_Log_Conf_Priority function obtains the configuration priority of a specified logical configuration on the
/// local machine.
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Add_Empty_Log_Conf
/// CM_Add_Empty_Log_Conf_Ex
/// CM_Get_First_Log_Conf
/// CM_Get_First_Log_Conf_Ex
/// CM_Get_Next_Log_Conf
/// CM_Get_Next_Log_Conf_Ex
///
///
/// Caller-supplied address of a location to receive a configuration priority value. For a list of priority values, see the
/// description of Priority for CM_Add_Empty_Log_Conf.
///
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Log_Conf_Priority returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_log_conf_priority CMAPI CONFIGRET
// CM_Get_Log_Conf_Priority( LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Log_Conf_Priority")]
public static extern CONFIGRET CM_Get_Log_Conf_Priority(LOG_CONF lcLogConf, out PRIORITY pPriority, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Log_Conf_Priority instead.]
///
///
/// The CM_Get_Log_Conf_Priority_Ex function obtains the configuration priority of a specified logical configuration on a
/// local or a remote machine.
///
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Add_Empty_Log_Conf
/// CM_Add_Empty_Log_Conf_Ex
/// CM_Get_First_Log_Conf
/// CM_Get_First_Log_Conf_Ex
/// CM_Get_Next_Log_Conf
/// CM_Get_Next_Log_Conf_Ex
///
///
/// Caller-supplied address of a location to receive a configuration priority value. For a list of priority values, see the
/// description of Priority for CM_Add_Empty_Log_Conf_Ex.
///
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Log_Conf_Priority_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_log_conf_priority_ex CMAPI CONFIGRET
// CM_Get_Log_Conf_Priority_Ex( LOG_CONF lcLogConf, PPRIORITY pPriority, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Log_Conf_Priority_Ex")]
public static extern CONFIGRET CM_Get_Log_Conf_Priority_Ex(LOG_CONF lcLogConf, out PRIORITY pPriority, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Next_Log_Conf function obtains the next logical configuration associated with a specific device instance on
/// the local machine.
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. (See the following Remarks section.
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Get_First_Log_Conf
/// CM_Get_Next_Log_Conf
///
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Log_Conf returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate the logical configurations associated with a device instance, call CM_Get_First_Log_Conf to obtain the first
/// logical configuration of a specified configuration type, then call CM_Get_Next_Log_Conf repeatedly until it returns CR_NO_MORE_LOG_CONF.
///
///
/// Calling CM_Add_Empty_Log_Conf or CM_Free_Log_Conf can invalidate the handle obtained from a previous call to
/// CM_Get_Next_Log_Conf. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf or
/// CM_Free_Log_Conf, your code must call CM_Get_First_Log_Conf again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_Next_Log_Conf is called with plcLogConf set to NULL, no handle is returned. This allows you to use the
/// return status to determine if a configuration exists without the need to subsequently free the handle.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_log_conf CMAPI CONFIGRET
// CM_Get_Next_Log_Conf( PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Log_Conf")]
public static extern CONFIGRET CM_Get_Next_Log_Conf(out SafeLOG_CONF plcLogConf, LOG_CONF lcLogConf, uint ulFlags = 0);
///
/// The CM_Get_Next_Log_Conf function obtains the next logical configuration associated with a specific device instance on
/// the local machine.
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. (See the following Remarks section.
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Get_First_Log_Conf
/// CM_Get_Next_Log_Conf
///
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Log_Conf returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate the logical configurations associated with a device instance, call CM_Get_First_Log_Conf to obtain the first
/// logical configuration of a specified configuration type, then call CM_Get_Next_Log_Conf repeatedly until it returns CR_NO_MORE_LOG_CONF.
///
///
/// Calling CM_Add_Empty_Log_Conf or CM_Free_Log_Conf can invalidate the handle obtained from a previous call to
/// CM_Get_Next_Log_Conf. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf or
/// CM_Free_Log_Conf, your code must call CM_Get_First_Log_Conf again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_Next_Log_Conf is called with plcLogConf set to NULL, no handle is returned. This allows you to use the
/// return status to determine if a configuration exists without the need to subsequently free the handle.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_log_conf CMAPI CONFIGRET
// CM_Get_Next_Log_Conf( PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Log_Conf")]
public static extern CONFIGRET CM_Get_Next_Log_Conf([In, Optional] IntPtr plcLogConf, LOG_CONF lcLogConf, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Next_Log_Conf instead.]
///
///
/// The CM_Get_Next_Log_Conf_Ex function obtains the next logical configuration associated with a specific device instance on
/// a local or a remote machine.
///
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. (See the following Remarks section.
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Get_First_Log_Conf_Ex
/// CM_Get_Next_Log_Conf_Ex
///
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Log_Conf_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate the logical configurations associated with a device instance, call CM_Get_First_Log_Conf_Ex to obtain the first
/// logical configuration, then call CM_Get_Next_Log_Conf_Ex repeatedly until it returns CR_NO_MORE_LOG_CONF.
///
///
/// Calling CM_Add_Empty_Log_Conf_Ex or CM_Free_Log_Conf_Ex can invalidate the handle obtained from a previous call to
/// CM_Get_Next_Log_Conf_Ex. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf_Ex
/// or CM_Free_Log_Conf_Ex, your code must call CM_Get_First_Log_Conf_Ex again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_Next_Log_Conf_Ex is called with plcLogConf set to NULL, no handle is returned. This allows you to use
/// the return status to determine if a configuration exists without the need to subsequently free the handle.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_log_conf_ex CMAPI CONFIGRET
// CM_Get_Next_Log_Conf_Ex( PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Log_Conf_Ex")]
public static extern CONFIGRET CM_Get_Next_Log_Conf_Ex(out SafeLOG_CONF plcLogConf, LOG_CONF lcLogConf, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Next_Log_Conf instead.]
///
///
/// The CM_Get_Next_Log_Conf_Ex function obtains the next logical configuration associated with a specific device instance on
/// a local or a remote machine.
///
///
///
/// Address of a location to receive the handle to a logical configuration, or NULL. (See the following Remarks section.
///
///
///
/// Caller-supplied handle to a logical configuration. This handle must have been previously obtained by calling one of the
/// following functions:
///
/// CM_Get_First_Log_Conf_Ex
/// CM_Get_Next_Log_Conf_Ex
///
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Log_Conf_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate the logical configurations associated with a device instance, call CM_Get_First_Log_Conf_Ex to obtain the first
/// logical configuration, then call CM_Get_Next_Log_Conf_Ex repeatedly until it returns CR_NO_MORE_LOG_CONF.
///
///
/// Calling CM_Add_Empty_Log_Conf_Ex or CM_Free_Log_Conf_Ex can invalidate the handle obtained from a previous call to
/// CM_Get_Next_Log_Conf_Ex. Thus if you want to obtain logical configurations after calling CM_Add_Empty_Log_Conf_Ex
/// or CM_Free_Log_Conf_Ex, your code must call CM_Get_First_Log_Conf_Ex again and start at the first configuration.
///
/// The handle received in plcLogConf must be explicitly freed by calling CM_Free_Log_Conf_Handle.
///
/// If CM_Get_Next_Log_Conf_Ex is called with plcLogConf set to NULL, no handle is returned. This allows you to use
/// the return status to determine if a configuration exists without the need to subsequently free the handle.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_log_conf_ex CMAPI CONFIGRET
// CM_Get_Next_Log_Conf_Ex( PLOG_CONF plcLogConf, LOG_CONF lcLogConf, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Log_Conf_Ex")]
public static extern CONFIGRET CM_Get_Next_Log_Conf_Ex([In, Optional] IntPtr plcLogConf, LOG_CONF lcLogConf, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Next_Res_Des function obtains a handle to the next resource descriptor, of a specified resource type, for a
/// logical configuration on the local machine.
///
/// Pointer to a location to receive a resource descriptor handle.
///
/// Caller-supplied handle to either a resource descriptor or a logical configuration. For more information, see the following
/// Remarks section.
///
///
/// Caller-supplied resource type identifier, indicating the type of resource descriptor being requested. This must be one of the
/// ResType_-prefixed constants defined in Cfgmgr32.h.
///
///
/// Pointer to a location to receive a resource type identifier, if ForResource specifies ResType_All. For any other
/// ForResource value, callers should set this to NULL.
///
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Res_Des returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate a logical configuration's resource descriptors, begin by calling CM_Get_Next_Res_Des with the logical
/// configuration's handle as the argument for rdResDes. This obtains a handle to the first resource descriptor of the type
/// specified by ForResource. Then for each subsequent call to CM_Get_Next_Res_Des, specify the most recently obtained
/// descriptor handle as the argument for rdResDes. Repeat until the function returns CR_NO_MORE_RES_DES.
///
/// To retrieve the information stored in a resource descriptor, call CM_Get_Res_Des_Data.
/// To modify the information stored in a resource descriptor, call CM_Modify_Res_Des.
///
/// Callers of CM_Get_Next_Res_Des must call CM_Free_Res_Des_Handle to deallocate the resource descriptor handle, after it is
/// no longer needed.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_res_des CMAPI CONFIGRET CM_Get_Next_Res_Des(
// PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, PRESOURCEID pResourceID, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Res_Des")]
public static extern CONFIGRET CM_Get_Next_Res_Des(out SafeRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, out RESOURCEID pResourceID, uint ulFlags = 0);
///
/// The CM_Get_Next_Res_Des function obtains a handle to the next resource descriptor, of a specified resource type, for a
/// logical configuration on the local machine.
///
/// Pointer to a location to receive a resource descriptor handle.
///
/// Caller-supplied handle to either a resource descriptor or a logical configuration. For more information, see the following
/// Remarks section.
///
///
/// Caller-supplied resource type identifier, indicating the type of resource descriptor being requested. This must be one of the
/// ResType_-prefixed constants defined in Cfgmgr32.h.
///
///
/// Pointer to a location to receive a resource type identifier, if ForResource specifies ResType_All. For any other
/// ForResource value, callers should set this to NULL.
///
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Res_Des returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate a logical configuration's resource descriptors, begin by calling CM_Get_Next_Res_Des with the logical
/// configuration's handle as the argument for rdResDes. This obtains a handle to the first resource descriptor of the type
/// specified by ForResource. Then for each subsequent call to CM_Get_Next_Res_Des, specify the most recently obtained
/// descriptor handle as the argument for rdResDes. Repeat until the function returns CR_NO_MORE_RES_DES.
///
/// To retrieve the information stored in a resource descriptor, call CM_Get_Res_Des_Data.
/// To modify the information stored in a resource descriptor, call CM_Modify_Res_Des.
///
/// Callers of CM_Get_Next_Res_Des must call CM_Free_Res_Des_Handle to deallocate the resource descriptor handle, after it is
/// no longer needed.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_res_des CMAPI CONFIGRET CM_Get_Next_Res_Des(
// PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, PRESOURCEID pResourceID, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Res_Des")]
public static extern CONFIGRET CM_Get_Next_Res_Des(out SafeRES_DES prdResDes, LOG_CONF rdResDes, RESOURCEID ForResource, out RESOURCEID pResourceID, uint ulFlags = 0);
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Next_Res_Des instead.]
///
/// The CM_Get_Next_Res_Des_Ex function obtains a handle to the next resource descriptor, of a specified resource type, for a
/// logical configuration on a local or a remote machine.
///
///
/// Pointer to a location to receive a resource descriptor handle.
///
/// Caller-supplied handle to either a resource descriptor or a logical configuration. For more information, see the following
/// Remarks section.
///
///
/// Caller-supplied resource type identifier, indicating the type of resource descriptor being requested. This must be one of the
/// ResType_-prefixed constants defined in Cfgmgr32.h.
///
///
/// Pointer to a location to receive a resource type identifier, if ForResource specifies ResType_All. For any other
/// ForResource value, callers should set this to NULL.
///
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Res_Des_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate a logical configuration's resource descriptors, begin by calling CM_Get_Next_Res_Des_Ex with the logical
/// configuration's handle as the argument for rdResDes. This obtains a handle to the first resource descriptor of the type
/// specified by ForResource. Then for each subsequent call to CM_Get_Next_Res_Des_Ex, specify the most recently obtained
/// descriptor handle as the argument for rdResDes. Repeat until the function returns CR_NO_MORE_RES_DES.
///
/// To retrieve the information stored in a resource descriptor, call CM_Get_Res_Des_Data_Ex.
/// To modify the information stored in a resource descriptor, call CM_Modify_Res_Des_Ex.
///
/// Callers of CM_Get_Next_Res_Des_Ex must call CM_Free_Res_Des_Handle to deallocate the resource descriptor handle, after it
/// is no longer needed.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_res_des_ex CMAPI CONFIGRET
// CM_Get_Next_Res_Des_Ex( PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, PRESOURCEID pResourceID, ULONG ulFlags,
// HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Res_Des_Ex")]
public static extern CONFIGRET CM_Get_Next_Res_Des_Ex(out SafeRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, out RESOURCEID pResourceID, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Next_Res_Des instead.]
///
/// The CM_Get_Next_Res_Des_Ex function obtains a handle to the next resource descriptor, of a specified resource type, for a
/// logical configuration on a local or a remote machine.
///
///
/// Pointer to a location to receive a resource descriptor handle.
///
/// Caller-supplied handle to either a resource descriptor or a logical configuration. For more information, see the following
/// Remarks section.
///
///
/// Caller-supplied resource type identifier, indicating the type of resource descriptor being requested. This must be one of the
/// ResType_-prefixed constants defined in Cfgmgr32.h.
///
///
/// Pointer to a location to receive a resource type identifier, if ForResource specifies ResType_All. For any other
/// ForResource value, callers should set this to NULL.
///
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Res_Des_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// To enumerate a logical configuration's resource descriptors, begin by calling CM_Get_Next_Res_Des_Ex with the logical
/// configuration's handle as the argument for rdResDes. This obtains a handle to the first resource descriptor of the type
/// specified by ForResource. Then for each subsequent call to CM_Get_Next_Res_Des_Ex, specify the most recently obtained
/// descriptor handle as the argument for rdResDes. Repeat until the function returns CR_NO_MORE_RES_DES.
///
/// To retrieve the information stored in a resource descriptor, call CM_Get_Res_Des_Data_Ex.
/// To modify the information stored in a resource descriptor, call CM_Modify_Res_Des_Ex.
///
/// Callers of CM_Get_Next_Res_Des_Ex must call CM_Free_Res_Des_Handle to deallocate the resource descriptor handle, after it
/// is no longer needed.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_next_res_des_ex CMAPI CONFIGRET
// CM_Get_Next_Res_Des_Ex( PRES_DES prdResDes, RES_DES rdResDes, RESOURCEID ForResource, PRESOURCEID pResourceID, ULONG ulFlags,
// HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Res_Des_Ex")]
public static extern CONFIGRET CM_Get_Next_Res_Des_Ex(out SafeRES_DES prdResDes, LOG_CONF rdResDes, RESOURCEID ForResource, out RESOURCEID pResourceID, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Parent instead.]
///
/// The CM_Get_Parent_Ex function obtains a device instance handle to the parent node of a specified device node (devnode) in
/// a local or a remote machine's device tree.
///
///
///
/// Caller-supplied pointer to the device instance handle to the parent node that this function retrieves. The retrieved handle is
/// bound to the machine handle specified by hMachine.
///
/// Caller-supplied device instance handle that is bound to the machine handle specified by hMachine.
/// Not used, must be zero.
///
/// Caller-supplied machine handle to which the caller-supplied device instance handle is bound.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_parent_ex CMAPI CONFIGRET CM_Get_Parent_Ex(
// PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Parent_Ex")]
public static extern CONFIGRET CM_Get_Parent_Ex(out uint pdnDevInst, uint dnDevInst, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
/// The CM_Get_Res_Des_Data function retrieves the information stored in a resource descriptor on the local machine.
/// Caller-supplied handle to a resource descriptor, obtained by a previous call to CM_Get_Next_Res_Des.
///
/// Address of a buffer to receive the contents of a resource descriptor. The required buffer size should be obtained by calling CM_Get_Res_Des_Data_Size.
///
/// Caller-supplied length of the buffer specified by Buffer.
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Res_Des_Data returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
/// Information returned in the buffer supplied by Buffer will be formatted as one of the resource type structures listed in the
/// description of CM_Add_Res_Des, based on the resource type that was specified when CM_Get_Next_Res_Des was called to obtain the
/// resource descriptor handle.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_res_des_data CMAPI CONFIGRET CM_Get_Res_Des_Data(
// RES_DES rdResDes, PVOID Buffer, ULONG BufferLen, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Res_Des_Data")]
public static extern CONFIGRET CM_Get_Res_Des_Data(RES_DES rdResDes, [Out] IntPtr Buffer, uint BufferLen, uint ulFlags = 0);
///
/// The CM_Get_Res_Des_Data function retrieves the information stored in a resource descriptor on the local machine.
///
/// The type of the data to retrieve.
/// Caller-supplied handle to a resource descriptor, obtained by a previous call to CM_Get_Next_Res_Des.
///
///
/// Returns the structure specified in as the contents of the resource descriptor.
///
///
/// Note Starting with Windows 8, CM_Get_Res_Des_Data throws CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Res_Des_Data")]
public static T CM_Get_Res_Des_Data(RES_DES rdResDes) where T : struct
{
CM_Get_Res_Des_Data_Size(out var size, rdResDes).ThrowIfFailed();
using var mem = new SafeCoTaskMemHandle(size);
CM_Get_Res_Des_Data(rdResDes, mem, size).ThrowIfFailed();
return mem.ToStructure();
}
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Res_Des_Data instead.]
///
/// The CM_Get_Res_Des_Data_Ex function retrieves the information stored in a resource descriptor on a local or a remote machine.
///
///
/// Caller-supplied handle to a resource descriptor, obtained by a previous call to CM_Get_Next_Res_Des_Ex.
///
/// Address of a buffer to receive the contents of a resource descriptor. The required buffer size should be obtained by calling CM_Get_Res_Des_Data_Size_Ex.
///
/// Caller-supplied length of the buffer specified by Buffer.
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Res_Des_Data_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// Information returned in the buffer supplied by Buffer will be formatted as one of the resource type structures listed in the
/// description of CM_Add_Res_Des_Ex, based on the resource type that was specified when CM_Get_Next_Res_Des_Ex was called to obtain
/// the resource descriptor handle.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_res_des_data_ex CMAPI CONFIGRET
// CM_Get_Res_Des_Data_Ex( RES_DES rdResDes, PVOID Buffer, ULONG BufferLen, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Res_Des_Data_Ex")]
public static extern CONFIGRET CM_Get_Res_Des_Data_Ex(RES_DES rdResDes, [Out] IntPtr Buffer, uint BufferLen, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Res_Des_Data_Size function obtains the buffer size required to hold the information contained in a specified
/// resource descriptor on the local machine.
///
/// Caller-supplied address of a location to receive the required buffer size.
/// Caller-supplied handle to a resource descriptor, obtained by a previous call to CM_Get_Next_Res_Des.
/// Not used, must be zero.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Res_Des_Data_Size returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
/// The returned size value represents the size of the appropriate resource structure (see CM_Add_Res_Des). If the resource
/// descriptor resides in a resource requirements list, the returned size includes both the size of the resource structure and the
/// space allocated for associated range arrays.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_res_des_data_size CMAPI CONFIGRET
// CM_Get_Res_Des_Data_Size( PULONG pulSize, RES_DES rdResDes, ULONG ulFlags );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Res_Des_Data_Size")]
public static extern CONFIGRET CM_Get_Res_Des_Data_Size(out uint pulSize, RES_DES rdResDes, uint ulFlags = 0);
///
///
/// [Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Res_Des_Data_Size instead.]
///
///
/// The CM_Get_Res_Des_Data_Size_Ex function obtains the buffer size required to hold the information contained in a
/// specified resource descriptor on a local or a remote machine.
///
///
/// Caller-supplied address of a location to receive the required buffer size.
/// Caller-supplied handle to a resource descriptor, obtained by a previous call to CM_Get_Next_Res_Des_Ex.
/// Not used, must be zero.
///
/// Caller-supplied machine handle, obtained from a previous call to CM_Connect_Machine.
///
/// Note Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as
/// this functionality has been removed.
///
///
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
/// Note Starting with Windows 8, CM_Get_Res_Des_Data_Size_Ex returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64
/// scenario. To request information about the hardware resources on a local machine it is necessary implement an
/// architecture-native version of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
///
///
///
/// The returned size value represents the size of the appropriate resource structure (see CM_Add_Res_Des_Ex). If the resource
/// descriptor resides in a resource requirements list, the returned size includes both the size of the resource structure and the
/// space allocated for associated range arrays.
///
///
/// Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus
/// you cannot access remote machines when running on these versions of Windows.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_res_des_data_size_ex CMAPI CONFIGRET
// CM_Get_Res_Des_Data_Size_Ex( PULONG pulSize, RES_DES rdResDes, ULONG ulFlags, HMACHINE hMachine );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Res_Des_Data_Size_Ex")]
public static extern CONFIGRET CM_Get_Res_Des_Data_Size_Ex(out uint pulSize, RES_DES rdResDes, [In, Optional] uint ulFlags, [In, Optional] HMACHINE hMachine);
///
/// The CM_Get_Next_Res_Des function obtains a handle to the next resource descriptor, of a specified resource type, for a
/// logical configuration on the local machine.
///
/// Handle to a logical configuration.
///
/// Caller-supplied resource type identifier, indicating the type of resource descriptor being requested. This must be one of the
/// ResType_-prefixed constants defined in Cfgmgr32.h.
///
/// A sequence of resource descriptor handles and their associated resource type identifiers.
///
///
/// Note Starting with Windows 8, CM_Get_Next_Res_Des returns CR_CALL_NOT_IMPLEMENTED when used in a Wow64 scenario.
/// To request information about the hardware resources on a local machine it is necessary implement an architecture-native version
/// of the application using the hardware resource APIs. For example: An AMD64 application for AMD64 systems.
///
/// To retrieve the information stored in a resource descriptor, call CM_Get_Res_Des_Data.
/// To modify the information stored in a resource descriptor, call CM_Modify_Res_Des.
///
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Next_Res_Des")]
public static IEnumerable<(SafeRES_DES prdResDes, RESOURCEID pResourceID)> CM_Get_Res_Des_List([In] LOG_CONF lcLogConf, RESOURCEID ForResource = RESOURCEID.ResType_All)
{
CONFIGRET ret = CM_Get_Next_Res_Des(out var rd, lcLogConf, ForResource, out var resId);
if (ret == CONFIGRET.CR_NO_MORE_RES_DES)
yield break;
ret.ThrowIfFailed();
yield return (rd, resId);
while ((ret = CM_Get_Next_Res_Des(out rd, rd, ForResource, out resId)) == CONFIGRET.CR_SUCCESS)
yield return (rd, resId);
if (ret != CONFIGRET.CR_NO_MORE_RES_DES) ret.ThrowIfFailed();
}
///
/// The CM_Get_Resource_Conflict_Count function obtains the number of conflicts contained in a specified resource conflict list.
///
/// Caller-supplied handle to a conflict list, obtained by a previous call to CM_Query_Resource_Conflict_List.
/// Caller-supplied address of a location to receive the conflict count.
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
///
/// The count value obtained by calling CM_Get_Resource_Conflict_Count can be used to determine the number of times to call
/// CM_Get_Resource_Conflict_Details, which supplies information about each conflict.
///
/// If there are no entries in the conflict list, the location supplied by pulCount will receive zero.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_resource_conflict_count CMAPI CONFIGRET
// CM_Get_Resource_Conflict_Count( CONFLICT_LIST clConflictList, PULONG pulCount );
[DllImport(Lib_Cfgmgr32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Resource_Conflict_Count")]
public static extern CONFIGRET CM_Get_Resource_Conflict_Count(CONFLICT_LIST clConflictList, out uint pulCount);
///
/// The CM_Get_Resource_Conflict_Details function obtains the details about one of the resource conflicts in a conflict list.
///
/// Caller-supplied handle to a conflict list, obtained by a previous call to CM_Query_Resource_Conflict_List.
///
/// Caller-supplied value used as an index into the conflict list. This value can be from zero to one less than the number returned
/// by CM_Get_Resource_Conflict_Count.
///
///
/// Caller-supplied address of a CONFLICT_DETAILS structure to receive conflict details. The caller must supply values for the
/// structure's CD_ulSize and CD_ulMask structures.
///
///
/// If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
///
///
/// To determine conflicting resource requirements between a specified device and other devices on a machine, use the following steps.
///
///
/// -
/// Call CM_Query_Resource_Conflict_List to obtain a handle to a list of resource conflicts.
///
/// -
/// Call CM_Get_Resource_Conflict_Count to determine the number of conflicts contained in the resource conflict list.
///
/// -
/// Call CM_Get_Resource_Conflict_Details for each entry in the conflict list.
///
///
/// The following conflicts are typically not reported:
///
/// -
///
/// If there are multiple conflicts for a resource, and the owners of only some of the conflicts can be determined, the conflicts
/// without identifiable owners are not reported.
///
///
/// -
/// Conflicts that appear to be with the specified device (that is, the device conflicts with itself) are not reported.
///
/// -
/// If multiple non-Plug and Play devices use the same driver, resource conflicts among these devices might not be reported.
///
///
/// Sometimes, resources assigned to the HAL might be reported as either conflicting with the HAL or not available.
///
// https://docs.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_resource_conflict_detailsw CMAPI CONFIGRET
// CM_Get_Resource_Conflict_DetailsW( CONFLICT_LIST clConflictList, ULONG ulIndex, PCONFLICT_DETAILS_W pConflictDetails );
[DllImport(Lib_Cfgmgr32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("cfgmgr32.h", MSDNShortId = "NF:cfgmgr32.CM_Get_Resource_Conflict_DetailsW")]
public static extern CONFIGRET CM_Get_Resource_Conflict_Details(CONFLICT_LIST clConflictList, uint ulIndex, ref CONFLICT_DETAILS pConflictDetails);
}