CM_Get_DevNode_Property_Keys (cfgmgr32)
Last changed: -109.42.113.142

.
Summary
Retrieves an array of the device property keys that represent the device properties that are set for a device instance.

C# Signature:

[DllImport("CfgMgr32.dll", CharSet = CharSet.Unicode)]
static extern ConfigManagerResult CM_Get_DevNode_Property_Keys(uint devInst, [Out]DEVPROPKEY[] propertyKeyArray,
     ref uint propertyKeyCount, uint zeroFlags);

User-Defined Types:

struct DEVPROPKEY {
     public DEVPROPKEY(Guid guid, uint pid) {
     _guid = guid;
     _pid = pid;
     }
     public Guid _guid;
     public uint _pid;
}

enum ConfigManagerResult : uint {
     Success = 0x00000000,
     Default = 0x00000001,
     OutOfMemory = 0x00000002,
     InvalidPointer = 0x00000003,
     InvalidFlag = 0x00000004,
     InvalidDevnode = 0x00000005,
     InvalidDevinst = InvalidDevnode,
     InvalidResDes = 0x00000006,
     InvalidLogConf = 0x00000007,
     InvalidArbitrator = 0x00000008,
     InvalidNodelist = 0x00000009,
     DevnodeHasReqs = 0x0000000A,
     DevinstHasReqs = DevnodeHasReqs,
     InvalidResourceid = 0x0000000B,
     NoSuchDevnode = 0x0000000D,
     NoSuchDevinst = NoSuchDevnode,
     NoMoreLogConf = 0x0000000E,
     NoMoreResDes = 0x0000000F,
     AlreadySuchDevnode = 0x00000010,
     AlreadySuchDevinst = AlreadySuchDevnode,
     InvalidRangeList = 0x00000011,
     InvalidRange = 0x00000012,
     Failure = 0x00000013,
     NoSuchLogicalDev = 0x00000014,
     CreateBlocked = 0x00000015,
     RemoveVetoed = 0x00000017,
     ApmVetoed = 0x00000018,
     InvalidLoadType = 0x00000019,
     BufferSmall = 0x0000001A,
     NoArbitrator = 0x0000001B,
     NoRegistryHandle = 0x0000001C,
     RegistryError = 0x0000001D,
     InvalidDeviceId = 0x0000001E,
     InvalidData = 0x0000001F,
     InvalidApi = 0x00000020,
     DevloaderNotReady = 0x00000021,
     NeedRestart = 0x00000022,
     NoMoreHwProfiles = 0x00000023,
     DeviceNotThere = 0x00000024,
     NoSuchValue = 0x00000025,
     WrongType = 0x00000026,
     InvalidPriority = 0x00000027,
     NotDisableable = 0x00000028,
     FreeResources = 0x00000029,
     QueryVetoed = 0x0000002A,
     CantShareIrq = 0x0000002B,
     NoDependent = 0x0000002C,
     SameResources = 0x0000002D,
     NoSuchRegistryKey = 0x0000002E,
     InvalidMachinename = 0x0000002F,   // NT ONLY
     RemoteCommFailure = 0x00000030,   // NT ONLY
     MachineUnavailable = 0x00000031,   // NT ONLY
     NoCmServices = 0x00000032,   // NT ONLY
     AccessDenied = 0x00000033,   // NT ONLY
     CallNotImplemented = 0x00000034,
     InvalidProperty = 0x00000035,
     DeviceInterfaceActive = 0x00000036,
     NoSuchDeviceInterface = 0x00000037,
     InvalidReferenceString = 0x00000038,
     InvalidConflictList = 0x00000039,
     InvalidIndex = 0x0000003A,
     InvalidStructureSize = 0x0000003B
}

Sample Code:

uint devInst = ...;
uint keyCount = 0;
result = CM_Get_DevNode_Property_Keys(devInst, null, ref keyCount, 0);
if (result != ConfigManagerResult.BufferSmall) {
     throw new Exception("Failed to retrieve key count: " + result + ".");
}
var keys = new DEVPROPKEY[keyCount];
result = CM_Get_DevNode_Property_Keys(devInst, keys, ref keyCount, 0);
if (result != ConfigManagerResult.Success) {
     throw new Exception("Failed to retrieve keys: " + result + ".");
}

Documentation