Mercurial > hg > ucis.core
annotate USBLib/Internal/Windows/SetupApi.cs @ 58:fd63c453ff65
Improved Windows USB enumeration classes
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 09 Oct 2013 20:54:15 +0200 |
parents | 556b4fb511bd |
children | 309c705d7460 |
rev | line source |
---|---|
21 | 1 using System; |
2 using System.Collections.Generic; | |
3 using System.Runtime.InteropServices; | |
4 using System.Text; | |
5 using Microsoft.Win32; | |
6 using Microsoft.Win32.SafeHandles; | |
22 | 7 using UCIS.HWLib.Windows.Devices; |
21 | 8 |
9 namespace UCIS.USBLib.Internal.Windows { | |
10 class SafeDeviceInfoSetHandle : SafeHandleZeroOrMinusOneIsInvalid { | |
11 public SafeDeviceInfoSetHandle() : base(true) { } | |
12 //public SafeDeviceInfoSetHandle(IntPtr handle) : base(true) { SetHandle(handle); } | |
13 protected override bool ReleaseHandle() { | |
14 if (IsInvalid) return true; | |
15 bool bSuccess = SetupApi.SetupDiDestroyDeviceInfoList(handle); | |
16 handle = IntPtr.Zero; | |
17 return bSuccess; | |
18 } | |
19 } | |
20 class SetupApi { | |
21 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
22 public static extern SafeDeviceInfoSetHandle SetupDiGetClassDevs(IntPtr ClassGuid, [MarshalAs(UnmanagedType.LPTStr)] string Enumerator, IntPtr hwndParent, int Flags); | |
23 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
24 public static extern SafeDeviceInfoSetHandle SetupDiGetClassDevsA(ref Guid ClassGuid, [MarshalAs(UnmanagedType.LPTStr)] string Enumerator, IntPtr hwndParent, DICFG Flags); | |
25 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
26 public static extern SafeDeviceInfoSetHandle SetupDiGetClassDevsA(IntPtr ClassGuid, [MarshalAs(UnmanagedType.LPStr)] string Enumerator, IntPtr hwndParent, DICFG Flags); | |
27 | |
28 [DllImport("setupapi.dll", CharSet = CharSet.Auto /*, SetLastError = true*/)] | |
29 public static extern bool SetupDiDestroyDeviceInfoList(IntPtr hDevInfo); | |
30 | |
31 [DllImport("setupapi.dll", SetLastError = true)] | |
32 public static extern bool SetupDiEnumDeviceInfo(SafeDeviceInfoSetHandle DeviceInfoSet, int MemberIndex, ref SP_DEVINFO_DATA DeviceInfoData); | |
33 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] | |
34 public static extern Boolean SetupDiEnumDeviceInterfaces(SafeDeviceInfoSetHandle hDevInfo, ref SP_DEVINFO_DATA devInfo, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData); | |
35 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] | |
36 public static extern Boolean SetupDiEnumDeviceInterfaces(SafeDeviceInfoSetHandle hDevInfo, IntPtr devInfo, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData); | |
37 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] | |
38 public static extern Boolean SetupDiGetDeviceInterfaceDetail(SafeDeviceInfoSetHandle hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, out int requiredSize, ref SP_DEVINFO_DATA deviceInfoData); | |
39 | |
40 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] | |
41 public static extern bool SetupDiGetCustomDeviceProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, string CustomPropertyName, DICUSTOMDEVPROP Flags, out RegistryValueKind PropertyRegDataType, Byte[] PropertyBuffer, int PropertyBufferSize, out int RequiredSize); | |
42 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Ansi)] | |
43 public static extern bool SetupDiGetDeviceInstanceIdA(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, StringBuilder DeviceInstanceId, int DeviceInstanceIdSize, out int RequiredSize); | |
44 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] | |
45 public static extern bool SetupDiGetDeviceRegistryProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPDRP Property, out RegistryValueKind PropertyRegDataType, byte[] PropertyBuffer, int PropertyBufferSize, out int RequiredSize); | |
46 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
47 public static extern bool SetupDiGetDeviceRegistryProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPDRP iProperty, out int PropertyRegDataType, IntPtr PropertyBuffer, int PropertyBufferSize, out int RequiredSize); | |
48 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
49 public static extern bool SetupDiGetDeviceRegistryProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPDRP iProperty, out int PropertyRegDataType, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder PropertyBuffer, int PropertyBufferSize, out int RequiredSize); | |
50
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
50 [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
51 public static extern bool SetupDiSetDeviceRegistryProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, SPDRP Property, Byte[] PropertyBuffer, UInt32 PropertyBufferSize); |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
52 |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
53 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
54 public static extern IntPtr SetupDiOpenDevRegKey(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, UInt32 Scope, UInt32 HwProfile, UInt32 KeyType, UInt32 samDesired); |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
55 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
56 public static extern bool SetupDiGetDeviceProperty(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, ref DEVPROPKEY PropertyKey, out UInt32 PropertyType, Byte[] PropertyBuffer, UInt32 PropertyBufferSize, out UInt32 RequiredSize, UInt32 Flags); |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
57 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
58 public static extern bool SetupDiGetDeviceInterfacePropertyKeys(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, byte[] propKeyBuffer, int propKeyBufferElements, out int RequiredPropertyKeyCount, int Flags); |
21 | 59 |
60 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
61 public static extern bool SetupDiGetDeviceInstanceId(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, StringBuilder DeviceInstanceId, int DeviceInstanceIdSize, out int RequiredSize); | |
62 | |
63 [DllImport("setupapi.dll")] | |
64 public static extern bool SetupDiSetClassInstallParams(SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, ref SP_CLASSINSTALL_HEADER ClassInstallParams, int ClassInstallParamsSize); | |
65 | |
66 [DllImport("setupapi.dll")] | |
67 public static extern bool SetupDiCallClassInstaller(int InstallFunction, SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData); | |
68 | |
69 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
70 public static extern CR CM_Get_Device_ID(UInt32 dnDevInst, StringBuilder Buffer, int BufferLen, int ulFlags); | |
71 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
72 public static extern CR CM_Get_Device_ID(UInt32 dnDevInst, IntPtr Buffer, int BufferLen, int ulFlags); | |
73 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
74 public static extern CR CM_Get_Device_ID_Size(out UInt32 pulLen, UInt32 dnDevInst, UInt32 ulFlags); | |
75 [DllImport("setupapi.dll")] | |
76 public static extern CR CM_Get_Parent(out UInt32 pdnDevInst, UInt32 dnDevInst, int ulFlags); | |
77 | |
78 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
79 public static extern CR CM_Locate_DevNode(out UInt32 pdnDevInst, [MarshalAs(UnmanagedType.LPWStr)] String pDeviceID, UInt32 ulFlags); | |
80 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
81 public static extern CR CM_Get_Sibling(out UInt32 pdnDevInst, UInt32 DevInst, UInt32 ulFlags); | |
82 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
83 public static extern CR CM_Get_Child(out UInt32 pdnDevInst, UInt32 dnDevInst, UInt32 ulFlags); | |
84 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
85 public static extern CR CM_Get_DevNode_Registry_Property(UInt32 dnDevInst, CMRDP ulProperty, out UInt32 pulRegDataType, Byte[] Buffer, ref UInt32 pulLength, UInt32 ulFlags); | |
86 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
87 public static extern CR CM_Get_Device_Interface_List([In] ref Guid InterfaceClassGuid, [MarshalAs(UnmanagedType.LPWStr)] String pDeviceID, Byte[] Buffer, UInt32 BufferLen, UInt32 ulFlags); | |
88 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
89 public static extern CR CM_Get_Device_Interface_List_Size(out UInt32 pulLen, [In] ref Guid InterfaceClassGuid, [MarshalAs(UnmanagedType.LPWStr)] String pDeviceID, UInt32 ulFlags); | |
90 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
91 public static extern CR CM_Enumerate_Classes(UInt32 ulClassIndex, out Guid ClassGuid, UInt32 ulFlags); | |
92 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] | |
93 public static extern CR CM_Get_DevNode_Status(out UInt32 pulStatus, out UInt32 pulProblemNumber, UInt32 dnDevInst, UInt32 ulFlags); | |
50
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
94 [DllImport("setupapi.dll", CharSet = CharSet.Auto)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
95 public static extern CR CM_Reenumerate_DevNode(UInt32 dnDevInst, UInt32 ulFlags); |
21 | 96 |
97 //public const int DIGCF_DEFAULT = 0x00000001; // only valid with DIGCF_DEVICEINTERFACE | |
98 public const int DIGCF_PRESENT = 0x00000002; | |
99 public const int DIGCF_ALLCLASSES = 0x00000004; | |
100 public const int DIGCF_PROFILE = 0x00000008; | |
101 public const int DIGCF_DEVICEINTERFACE = 0x00000010; | |
102 | |
103 internal static Guid? GetAsGuid(byte[] buffer) { if (buffer == null) return null; else return GetAsGuid(buffer, buffer.Length); } | |
104 internal static Guid GetAsGuid(byte[] buffer, int len) { | |
105 if (len != 16) return Guid.Empty; | |
106 byte[] guidBytes = new byte[len]; | |
107 Array.Copy(buffer, guidBytes, guidBytes.Length); | |
108 return new Guid(guidBytes); | |
109 } | |
110 internal static string GetAsString(byte[] buffer) { return GetAsString(buffer, buffer.Length); } | |
111 internal static string GetAsString(byte[] buffer, int len) { | |
112 if (len <= 2) return String.Empty; | |
113 return Encoding.Unicode.GetString(buffer, 0, len).TrimEnd('\0'); | |
114 } | |
115 internal static string[] GetAsStringArray(byte[] buffer) { return GetAsStringArray(buffer, buffer.Length); } | |
116 internal static string[] GetAsStringArray(byte[] buffer, int len) { | |
117 return GetAsString(buffer, len).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); | |
118 } | |
119 internal static Int32? GetAsInt32(byte[] buffer) { if (buffer == null) return null; else return GetAsInt32(buffer, buffer.Length); } | |
120 internal static Int32 GetAsInt32(byte[] buffer, int len) { | |
121 if (len != 4) return 0; | |
122 return buffer[0] | ((buffer[1]) << 8) | ((buffer[2]) << 16) | ((buffer[3]) << 24); | |
123 } | |
124 | |
125 public static IDictionary<String, Object> GetSPDRPProperties(DeviceNode device) { | |
126 Dictionary<string, object> deviceProperties = new Dictionary<string, object>(); | |
127 foreach (SPDRP prop in Enum.GetValues(typeof(SPDRP))) { | |
128 Byte[] propBuffer = device.GetProperty(prop); | |
129 if (propBuffer == null) continue; | |
130 int iReturnBytes = propBuffer.Length; | |
131 object oValue = null; | |
132 switch (prop) { | |
133 case SPDRP.PhysicalDeviceObjectName: | |
134 case SPDRP.LocationInformation: | |
135 case SPDRP.Class: | |
136 case SPDRP.Mfg: | |
137 case SPDRP.DeviceDesc: | |
138 case SPDRP.Driver: | |
139 case SPDRP.EnumeratorName: | |
140 case SPDRP.FriendlyName: | |
141 case SPDRP.ClassGuid: | |
142 case SPDRP.Service: | |
143 oValue = GetAsString(propBuffer, iReturnBytes); | |
144 break; | |
145 case SPDRP.HardwareId: | |
146 case SPDRP.CompatibleIds: | |
147 case SPDRP.LocationPaths: | |
148 oValue = GetAsStringArray(propBuffer, iReturnBytes); | |
149 break; | |
150 case SPDRP.BusNumber: | |
151 case SPDRP.InstallState: | |
152 case SPDRP.LegacyBusType: | |
153 case SPDRP.RemovalPolicy: | |
154 case SPDRP.UiNumber: | |
155 case SPDRP.Address: | |
156 oValue = GetAsInt32(propBuffer, iReturnBytes); | |
157 break; | |
158 case SPDRP.BusTypeGuid: | |
159 oValue = GetAsGuid(propBuffer, iReturnBytes); | |
160 break; | |
161 default: | |
162 oValue = propBuffer; | |
163 break; | |
164 } | |
165 deviceProperties.Add(prop.ToString(), oValue); | |
166 } | |
167 return deviceProperties; | |
168 } | |
169 } | |
170 | |
171 [StructLayout(LayoutKind.Sequential)] | |
172 struct SP_DEVICE_INTERFACE_DATA { | |
173 public UInt32 cbSize; | |
174 public Guid interfaceClassGuid; | |
175 public UInt32 flags; | |
176 private UIntPtr reserved; | |
177 public SP_DEVICE_INTERFACE_DATA(Boolean b) : this() { | |
178 cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVICE_INTERFACE_DATA)); | |
179 } | |
180 } | |
181 [StructLayout(LayoutKind.Sequential)] | |
182 struct SP_DEVINFO_DATA { | |
183 public UInt32 cbSize; | |
184 public Guid ClassGuid; | |
185 public UInt32 DevInst; | |
186 public IntPtr Reserved; | |
187 public SP_DEVINFO_DATA(Boolean b) | |
188 : this() { | |
189 cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA)); | |
190 } | |
191 } | |
192 [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] | |
193 struct SP_DEVICE_INTERFACE_DETAIL_DATA { | |
194 public uint cbSize; //<summary>The size, in bytes, of the fixed portion of the SP_DEVICE_INTERFACE_DETAIL_DATA structure.</summary> | |
195 //Byte[1] DevicePath | |
196 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] | |
197 public String DevicePath; //<summary>A NULL-terminated string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile.</summary> | |
198 public SP_DEVICE_INTERFACE_DETAIL_DATA(Boolean b) | |
199 : this() { | |
200 //cbSize should be sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) which is the same as the following | |
201 //if DevicePath is a 1-byte array and the structure is properly padded... is it really? | |
202 if (IntPtr.Size == 8) cbSize = 8; //Workaround for x64 | |
203 else cbSize = 4 + (uint)Marshal.SystemDefaultCharSize; | |
204 } | |
205 } | |
206 | |
50
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
207 [StructLayout(LayoutKind.Sequential)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
208 struct DEVPROPKEY { |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
209 public Guid fmtid; |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
210 public UInt32 pid; |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
211 } |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
212 |
21 | 213 enum CR { |
214 SUCCESS = (0x00000000), | |
215 DEFAULT = (0x00000001), | |
216 OUT_OF_MEMORY = (0x00000002), | |
217 INVALID_POINTER = (0x00000003), | |
218 INVALID_FLAG = (0x00000004), | |
219 INVALID_DEVNODE = (0x00000005), | |
220 INVALID_DEVINST = INVALID_DEVNODE, | |
221 INVALID_RES_DES = (0x00000006), | |
222 INVALID_LOG_CONF = (0x00000007), | |
223 INVALID_ARBITRATOR = (0x00000008), | |
224 INVALID_NODELIST = (0x00000009), | |
225 DEVNODE_HAS_REQS = (0x0000000A), | |
226 DEVINST_HAS_REQS = DEVNODE_HAS_REQS, | |
227 INVALID_RESOURCEID = (0x0000000B), | |
228 DLVXD_NOT_FOUND = (0x0000000C), // WIN 95 ONLY | |
229 NO_SUCH_DEVNODE = (0x0000000D), | |
230 NO_SUCH_DEVINST = NO_SUCH_DEVNODE, | |
231 NO_MORE_LOG_CONF = (0x0000000E), | |
232 NO_MORE_RES_DES = (0x0000000F), | |
233 ALREADY_SUCH_DEVNODE = (0x00000010), | |
234 ALREADY_SUCH_DEVINST = ALREADY_SUCH_DEVNODE, | |
235 INVALID_RANGE_LIST = (0x00000011), | |
236 INVALID_RANGE = (0x00000012), | |
237 FAILURE = (0x00000013), | |
238 NO_SUCH_LOGICAL_DEV = (0x00000014), | |
239 CREATE_BLOCKED = (0x00000015), | |
240 NOT_SYSTEM_VM = (0x00000016), // WIN 95 ONLY | |
241 REMOVE_VETOED = (0x00000017), | |
242 APM_VETOED = (0x00000018), | |
243 INVALID_LOAD_TYPE = (0x00000019), | |
244 BUFFER_SMALL = (0x0000001A), | |
245 NO_ARBITRATOR = (0x0000001B), | |
246 NO_REGISTRY_HANDLE = (0x0000001C), | |
247 REGISTRY_ERROR = (0x0000001D), | |
248 INVALID_DEVICE_ID = (0x0000001E), | |
249 INVALID_DATA = (0x0000001F), | |
250 INVALID_API = (0x00000020), | |
251 DEVLOADER_NOT_READY = (0x00000021), | |
252 NEED_RESTART = (0x00000022), | |
253 NO_MORE_HW_PROFILES = (0x00000023), | |
254 DEVICE_NOT_THERE = (0x00000024), | |
255 NO_SUCH_VALUE = (0x00000025), | |
256 WRONG_TYPE = (0x00000026), | |
257 INVALID_PRIORITY = (0x00000027), | |
258 NOT_DISABLEABLE = (0x00000028), | |
259 FREE_RESOURCES = (0x00000029), | |
260 QUERY_VETOED = (0x0000002A), | |
261 CANT_SHARE_IRQ = (0x0000002B), | |
262 NO_DEPENDENT = (0x0000002C), | |
263 SAME_RESOURCES = (0x0000002D), | |
264 NO_SUCH_REGISTRY_KEY = (0x0000002E), | |
265 INVALID_MACHINENAME = (0x0000002F), // NT ONLY | |
266 REMOTE_COMM_FAILURE = (0x00000030), // NT ONLY | |
267 MACHINE_UNAVAILABLE = (0x00000031), // NT ONLY | |
268 NO_CM_SERVICES = (0x00000032), // NT ONLY | |
269 ACCESS_DENIED = (0x00000033), // NT ONLY | |
270 CALL_NOT_IMPLEMENTED = (0x00000034), | |
271 INVALID_PROPERTY = (0x00000035), | |
272 DEVICE_INTERFACE_ACTIVE = (0x00000036), | |
273 NO_SUCH_DEVICE_INTERFACE = (0x00000037), | |
274 INVALID_REFERENCE_STRING = (0x00000038), | |
275 INVALID_CONFLICT_LIST = (0x00000039), | |
276 INVALID_INDEX = (0x0000003A), | |
277 INVALID_STRUCTURE_SIZE = (0x0000003B), | |
278 NUM_CR_RESULTS = (0x0000003C) | |
279 } | |
280 [Flags] | |
281 enum DICFG { | |
282 /// <summary> | |
283 /// Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes. | |
284 /// only valid with <see cref="DEVICEINTERFACE"/>. | |
285 /// </summary> | |
286 DEFAULT = 0x00000001, | |
287 /// <summary> | |
288 /// Return only devices that are currently present in a system. | |
289 /// </summary> | |
290 PRESENT = 0x00000002, | |
291 /// <summary> | |
292 /// Return a list of installed devices for all device setup classes or all device interface classes. | |
293 /// </summary> | |
294 ALLCLASSES = 0x00000004, | |
295 /// <summary> | |
296 /// Return only devices that are a part of the current hardware profile. | |
297 /// </summary> | |
298 PROFILE = 0x00000008, | |
299 /// <summary> | |
300 /// Return devices that support device interfaces for the specified device interface classes. | |
301 /// </summary> | |
302 DEVICEINTERFACE = 0x00000010, | |
303 } | |
304 enum DICUSTOMDEVPROP { | |
305 NONE = 0, | |
306 MERGE_MULTISZ = 0x00000001, | |
307 } | |
308 public enum SPDRP { | |
309 /// <summary> | |
310 /// Requests a string describing the device, such as "Microsoft PS/2 Port Mouse", typically defined by the manufacturer. | |
311 /// </summary> | |
312 DeviceDesc = (0x00000000), | |
313 /// <summary> | |
314 /// Requests the hardware IDs provided by the device that identify the device. | |
315 /// </summary> | |
316 HardwareId = (0x00000001), | |
317 /// <summary> | |
318 /// Requests the compatible IDs reported by the device. | |
319 /// </summary> | |
320 CompatibleIds = (0x00000002), | |
321 Service = 0x00000004, | |
322 /// <summary> | |
323 /// Requests the name of the device's setup class, in text format. | |
324 /// </summary> | |
325 Class = (0x00000007), | |
326 /// <summary> | |
327 /// Requests the GUID for the device's setup class. | |
328 /// </summary> | |
329 ClassGuid = (0x00000008), | |
330 /// <summary> | |
331 /// Requests the name of the driver-specific registry key. | |
332 /// </summary> | |
333 Driver = (0x00000009), | |
334 ConfigFlags = 0x0000000A, | |
335 /// <summary> | |
336 /// Requests a string identifying the manufacturer of the device. | |
337 /// </summary> | |
338 Mfg = (0x0000000B), | |
339 /// <summary> | |
340 /// Requests a string that can be used to distinguish between two similar devices, typically defined by the class installer. | |
341 /// </summary> | |
342 FriendlyName = (0x0000000C), | |
343 /// <summary> | |
344 /// Requests information about the device's location on the bus; the interpretation of this information is bus-specific. | |
345 /// </summary> | |
346 LocationInformation = (0x0000000D), | |
347 /// <summary> | |
348 /// Requests the name of the PDO for this device. | |
349 /// </summary> | |
350 PhysicalDeviceObjectName = (0x0000000E), | |
351 Capabilities = 0x0000000F, | |
352 /// <summary> | |
353 /// Requests a number associated with the device that can be displayed in the user interface. | |
354 /// </summary> | |
355 UiNumber = (0x00000010), | |
356 UpperFilters = 0x00000011, | |
357 LowerFilters = 0x00000012, | |
358 /// <summary> | |
359 /// Requests the GUID for the bus that the device is connected to. | |
360 /// </summary> | |
361 BusTypeGuid = (0x00000013), | |
362 /// <summary> | |
363 /// Requests the bus type, such as PCIBus or PCMCIABus. | |
364 /// </summary> | |
365 LegacyBusType = (0x00000014), | |
366 /// <summary> | |
367 /// Requests the legacy bus number of the bus the device is connected to. | |
368 /// </summary> | |
369 BusNumber = (0x00000015), | |
370 /// <summary> | |
371 /// Requests the name of the enumerator for the device, such as "USB". | |
372 /// </summary> | |
373 EnumeratorName = (0x00000016), | |
374 DevType = 0x00000019, | |
375 Exclusive = 0x0000001A, | |
376 Characteristics = 0x0000001B, | |
377 /// <summary> | |
378 /// Requests the address of the device on the bus. | |
379 /// </summary> | |
380 Address = (0x0000001C), | |
381 /// <summary> | |
382 /// (Windows XP and later.) Requests the device's current removal policy. The operating system uses this value as a hint to determine how the device is normally removed. | |
383 /// </summary> | |
384 RemovalPolicy = (0x0000001F), | |
385 /// <summary> | |
386 /// Windows XP and later.) Requests the device's installation state. | |
387 /// </summary> | |
388 InstallState = (0x00000022), | |
389 /// <summary> | |
390 /// Device Location Paths (R) | |
391 /// </summary> | |
392 LocationPaths = (0x00000023), | |
393 } | |
394 public enum CMRDP : uint { | |
395 DEVICEDESC = 0x00000001, | |
396 HARDWAREID = 0x00000002, | |
397 COMPATIBLEIDS = 0x00000003, | |
398 SERVICE = 0x00000005, | |
399 CLASS = 0x00000008, | |
400 CLASSGUID = 0x00000009, | |
401 DRIVER = 0x0000000A, | |
402 CONFIGFLAGS = 0x0000000B, | |
403 MFG = 0x0000000C, | |
404 FRIENDLYNAME = 0x0000000D, | |
405 LOCATION_INFORMATION = 0x0000000E, | |
406 PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000F, | |
407 CAPABILITIES = 0x00000010, | |
408 UI_NUMBER = 0x00000011, | |
409 UPPERFILTERS = 0x00000012, | |
410 LOWERFILTERS = 0x00000013, | |
411 BUSTYPEGUID = 0x00000014, | |
412 LEGACYBUSTYPE = 0x00000015, | |
413 BUSNUMBER = 0x00000016, | |
414 ENUMERATOR_NAME = 0x00000017, | |
415 } | |
416 } |