Mercurial > hg > ucis.core
annotate USBLib/Internal/Windows/SetupApi.cs @ 111:df53bdd49507 default tip
Merge
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 07 Nov 2014 18:37:39 +0100 |
parents | d467cd38b34e |
children |
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 |
93
d467cd38b34e
USBLib: fix for large transfers with libusb0 on Windows, added driver uninstall function
Ivo Smits <Ivo@UCIS.nl>
parents:
63
diff
changeset
|
97 [DllImport("newdev.dll", SetLastError = true, CharSet = CharSet.Auto)] |
d467cd38b34e
USBLib: fix for large transfers with libusb0 on Windows, added driver uninstall function
Ivo Smits <Ivo@UCIS.nl>
parents:
63
diff
changeset
|
98 public static extern bool DiUninstallDevice(IntPtr hwndParent, SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, UInt32 Flags, out Boolean NeedReboot); |
d467cd38b34e
USBLib: fix for large transfers with libusb0 on Windows, added driver uninstall function
Ivo Smits <Ivo@UCIS.nl>
parents:
63
diff
changeset
|
99 |
21 | 100 //public const int DIGCF_DEFAULT = 0x00000001; // only valid with DIGCF_DEVICEINTERFACE |
101 public const int DIGCF_PRESENT = 0x00000002; | |
102 public const int DIGCF_ALLCLASSES = 0x00000004; | |
103 public const int DIGCF_PROFILE = 0x00000008; | |
104 public const int DIGCF_DEVICEINTERFACE = 0x00000010; | |
105 | |
106 internal static Guid? GetAsGuid(byte[] buffer) { if (buffer == null) return null; else return GetAsGuid(buffer, buffer.Length); } | |
107 internal static Guid GetAsGuid(byte[] buffer, int len) { | |
108 if (len != 16) return Guid.Empty; | |
109 byte[] guidBytes = new byte[len]; | |
110 Array.Copy(buffer, guidBytes, guidBytes.Length); | |
111 return new Guid(guidBytes); | |
112 } | |
113 internal static string GetAsString(byte[] buffer) { return GetAsString(buffer, buffer.Length); } | |
114 internal static string GetAsString(byte[] buffer, int len) { | |
115 if (len <= 2) return String.Empty; | |
116 return Encoding.Unicode.GetString(buffer, 0, len).TrimEnd('\0'); | |
117 } | |
118 internal static string[] GetAsStringArray(byte[] buffer) { return GetAsStringArray(buffer, buffer.Length); } | |
119 internal static string[] GetAsStringArray(byte[] buffer, int len) { | |
120 return GetAsString(buffer, len).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); | |
121 } | |
122 internal static Int32? GetAsInt32(byte[] buffer) { if (buffer == null) return null; else return GetAsInt32(buffer, buffer.Length); } | |
123 internal static Int32 GetAsInt32(byte[] buffer, int len) { | |
124 if (len != 4) return 0; | |
125 return buffer[0] | ((buffer[1]) << 8) | ((buffer[2]) << 16) | ((buffer[3]) << 24); | |
126 } | |
127 | |
128 public static IDictionary<String, Object> GetSPDRPProperties(DeviceNode device) { | |
129 Dictionary<string, object> deviceProperties = new Dictionary<string, object>(); | |
130 foreach (SPDRP prop in Enum.GetValues(typeof(SPDRP))) { | |
131 Byte[] propBuffer = device.GetProperty(prop); | |
132 if (propBuffer == null) continue; | |
133 int iReturnBytes = propBuffer.Length; | |
134 object oValue = null; | |
135 switch (prop) { | |
136 case SPDRP.PhysicalDeviceObjectName: | |
137 case SPDRP.LocationInformation: | |
138 case SPDRP.Class: | |
139 case SPDRP.Mfg: | |
140 case SPDRP.DeviceDesc: | |
141 case SPDRP.Driver: | |
142 case SPDRP.EnumeratorName: | |
143 case SPDRP.FriendlyName: | |
144 case SPDRP.ClassGuid: | |
145 case SPDRP.Service: | |
146 oValue = GetAsString(propBuffer, iReturnBytes); | |
147 break; | |
148 case SPDRP.HardwareId: | |
149 case SPDRP.CompatibleIds: | |
150 case SPDRP.LocationPaths: | |
151 oValue = GetAsStringArray(propBuffer, iReturnBytes); | |
152 break; | |
153 case SPDRP.BusNumber: | |
154 case SPDRP.InstallState: | |
155 case SPDRP.LegacyBusType: | |
156 case SPDRP.RemovalPolicy: | |
157 case SPDRP.UiNumber: | |
158 case SPDRP.Address: | |
159 oValue = GetAsInt32(propBuffer, iReturnBytes); | |
160 break; | |
161 case SPDRP.BusTypeGuid: | |
162 oValue = GetAsGuid(propBuffer, iReturnBytes); | |
163 break; | |
164 default: | |
165 oValue = propBuffer; | |
166 break; | |
167 } | |
168 deviceProperties.Add(prop.ToString(), oValue); | |
169 } | |
170 return deviceProperties; | |
171 } | |
172 } | |
173 | |
174 [StructLayout(LayoutKind.Sequential)] | |
175 struct SP_DEVICE_INTERFACE_DATA { | |
176 public UInt32 cbSize; | |
177 public Guid interfaceClassGuid; | |
178 public UInt32 flags; | |
179 private UIntPtr reserved; | |
180 public SP_DEVICE_INTERFACE_DATA(Boolean b) : this() { | |
181 cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVICE_INTERFACE_DATA)); | |
182 } | |
183 } | |
184 [StructLayout(LayoutKind.Sequential)] | |
185 struct SP_DEVINFO_DATA { | |
186 public UInt32 cbSize; | |
187 public Guid ClassGuid; | |
188 public UInt32 DevInst; | |
189 public IntPtr Reserved; | |
190 public SP_DEVINFO_DATA(Boolean b) | |
191 : this() { | |
192 cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA)); | |
193 } | |
194 } | |
195 [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] | |
196 struct SP_DEVICE_INTERFACE_DETAIL_DATA { | |
197 public uint cbSize; //<summary>The size, in bytes, of the fixed portion of the SP_DEVICE_INTERFACE_DETAIL_DATA structure.</summary> | |
198 //Byte[1] DevicePath | |
199 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] | |
200 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> | |
201 public SP_DEVICE_INTERFACE_DETAIL_DATA(Boolean b) | |
202 : this() { | |
203 //cbSize should be sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) which is the same as the following | |
204 //if DevicePath is a 1-byte array and the structure is properly padded... is it really? | |
205 if (IntPtr.Size == 8) cbSize = 8; //Workaround for x64 | |
206 else cbSize = 4 + (uint)Marshal.SystemDefaultCharSize; | |
207 } | |
208 } | |
209 | |
50
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
210 [StructLayout(LayoutKind.Sequential)] |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
211 struct DEVPROPKEY { |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
212 public Guid fmtid; |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
213 public UInt32 pid; |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
214 } |
556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
Ivo Smits <Ivo@UCIS.nl>
parents:
22
diff
changeset
|
215 |
21 | 216 enum CR { |
217 SUCCESS = (0x00000000), | |
218 DEFAULT = (0x00000001), | |
219 OUT_OF_MEMORY = (0x00000002), | |
220 INVALID_POINTER = (0x00000003), | |
221 INVALID_FLAG = (0x00000004), | |
222 INVALID_DEVNODE = (0x00000005), | |
223 INVALID_DEVINST = INVALID_DEVNODE, | |
224 INVALID_RES_DES = (0x00000006), | |
225 INVALID_LOG_CONF = (0x00000007), | |
226 INVALID_ARBITRATOR = (0x00000008), | |
227 INVALID_NODELIST = (0x00000009), | |
228 DEVNODE_HAS_REQS = (0x0000000A), | |
229 DEVINST_HAS_REQS = DEVNODE_HAS_REQS, | |
230 INVALID_RESOURCEID = (0x0000000B), | |
231 DLVXD_NOT_FOUND = (0x0000000C), // WIN 95 ONLY | |
232 NO_SUCH_DEVNODE = (0x0000000D), | |
233 NO_SUCH_DEVINST = NO_SUCH_DEVNODE, | |
234 NO_MORE_LOG_CONF = (0x0000000E), | |
235 NO_MORE_RES_DES = (0x0000000F), | |
236 ALREADY_SUCH_DEVNODE = (0x00000010), | |
237 ALREADY_SUCH_DEVINST = ALREADY_SUCH_DEVNODE, | |
238 INVALID_RANGE_LIST = (0x00000011), | |
239 INVALID_RANGE = (0x00000012), | |
240 FAILURE = (0x00000013), | |
241 NO_SUCH_LOGICAL_DEV = (0x00000014), | |
242 CREATE_BLOCKED = (0x00000015), | |
243 NOT_SYSTEM_VM = (0x00000016), // WIN 95 ONLY | |
244 REMOVE_VETOED = (0x00000017), | |
245 APM_VETOED = (0x00000018), | |
246 INVALID_LOAD_TYPE = (0x00000019), | |
247 BUFFER_SMALL = (0x0000001A), | |
248 NO_ARBITRATOR = (0x0000001B), | |
249 NO_REGISTRY_HANDLE = (0x0000001C), | |
250 REGISTRY_ERROR = (0x0000001D), | |
251 INVALID_DEVICE_ID = (0x0000001E), | |
252 INVALID_DATA = (0x0000001F), | |
253 INVALID_API = (0x00000020), | |
254 DEVLOADER_NOT_READY = (0x00000021), | |
255 NEED_RESTART = (0x00000022), | |
256 NO_MORE_HW_PROFILES = (0x00000023), | |
257 DEVICE_NOT_THERE = (0x00000024), | |
258 NO_SUCH_VALUE = (0x00000025), | |
259 WRONG_TYPE = (0x00000026), | |
260 INVALID_PRIORITY = (0x00000027), | |
261 NOT_DISABLEABLE = (0x00000028), | |
262 FREE_RESOURCES = (0x00000029), | |
263 QUERY_VETOED = (0x0000002A), | |
264 CANT_SHARE_IRQ = (0x0000002B), | |
265 NO_DEPENDENT = (0x0000002C), | |
266 SAME_RESOURCES = (0x0000002D), | |
267 NO_SUCH_REGISTRY_KEY = (0x0000002E), | |
268 INVALID_MACHINENAME = (0x0000002F), // NT ONLY | |
269 REMOTE_COMM_FAILURE = (0x00000030), // NT ONLY | |
270 MACHINE_UNAVAILABLE = (0x00000031), // NT ONLY | |
271 NO_CM_SERVICES = (0x00000032), // NT ONLY | |
272 ACCESS_DENIED = (0x00000033), // NT ONLY | |
273 CALL_NOT_IMPLEMENTED = (0x00000034), | |
274 INVALID_PROPERTY = (0x00000035), | |
275 DEVICE_INTERFACE_ACTIVE = (0x00000036), | |
276 NO_SUCH_DEVICE_INTERFACE = (0x00000037), | |
277 INVALID_REFERENCE_STRING = (0x00000038), | |
278 INVALID_CONFLICT_LIST = (0x00000039), | |
279 INVALID_INDEX = (0x0000003A), | |
280 INVALID_STRUCTURE_SIZE = (0x0000003B), | |
281 NUM_CR_RESULTS = (0x0000003C) | |
282 } | |
283 [Flags] | |
284 enum DICFG { | |
285 /// <summary> | |
286 /// Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes. | |
287 /// only valid with <see cref="DEVICEINTERFACE"/>. | |
288 /// </summary> | |
289 DEFAULT = 0x00000001, | |
290 /// <summary> | |
291 /// Return only devices that are currently present in a system. | |
292 /// </summary> | |
293 PRESENT = 0x00000002, | |
294 /// <summary> | |
295 /// Return a list of installed devices for all device setup classes or all device interface classes. | |
296 /// </summary> | |
297 ALLCLASSES = 0x00000004, | |
298 /// <summary> | |
299 /// Return only devices that are a part of the current hardware profile. | |
300 /// </summary> | |
301 PROFILE = 0x00000008, | |
302 /// <summary> | |
303 /// Return devices that support device interfaces for the specified device interface classes. | |
304 /// </summary> | |
305 DEVICEINTERFACE = 0x00000010, | |
306 } | |
307 enum DICUSTOMDEVPROP { | |
308 NONE = 0, | |
309 MERGE_MULTISZ = 0x00000001, | |
310 } | |
311 public enum SPDRP { | |
312 /// <summary> | |
313 /// Requests a string describing the device, such as "Microsoft PS/2 Port Mouse", typically defined by the manufacturer. | |
314 /// </summary> | |
315 DeviceDesc = (0x00000000), | |
316 /// <summary> | |
317 /// Requests the hardware IDs provided by the device that identify the device. | |
318 /// </summary> | |
319 HardwareId = (0x00000001), | |
320 /// <summary> | |
321 /// Requests the compatible IDs reported by the device. | |
322 /// </summary> | |
323 CompatibleIds = (0x00000002), | |
324 Service = 0x00000004, | |
325 /// <summary> | |
326 /// Requests the name of the device's setup class, in text format. | |
327 /// </summary> | |
328 Class = (0x00000007), | |
329 /// <summary> | |
330 /// Requests the GUID for the device's setup class. | |
331 /// </summary> | |
332 ClassGuid = (0x00000008), | |
333 /// <summary> | |
334 /// Requests the name of the driver-specific registry key. | |
335 /// </summary> | |
336 Driver = (0x00000009), | |
337 ConfigFlags = 0x0000000A, | |
338 /// <summary> | |
339 /// Requests a string identifying the manufacturer of the device. | |
340 /// </summary> | |
341 Mfg = (0x0000000B), | |
342 /// <summary> | |
343 /// Requests a string that can be used to distinguish between two similar devices, typically defined by the class installer. | |
344 /// </summary> | |
345 FriendlyName = (0x0000000C), | |
346 /// <summary> | |
347 /// Requests information about the device's location on the bus; the interpretation of this information is bus-specific. | |
348 /// </summary> | |
349 LocationInformation = (0x0000000D), | |
350 /// <summary> | |
351 /// Requests the name of the PDO for this device. | |
352 /// </summary> | |
353 PhysicalDeviceObjectName = (0x0000000E), | |
354 Capabilities = 0x0000000F, | |
355 /// <summary> | |
356 /// Requests a number associated with the device that can be displayed in the user interface. | |
357 /// </summary> | |
358 UiNumber = (0x00000010), | |
359 UpperFilters = 0x00000011, | |
360 LowerFilters = 0x00000012, | |
361 /// <summary> | |
362 /// Requests the GUID for the bus that the device is connected to. | |
363 /// </summary> | |
364 BusTypeGuid = (0x00000013), | |
365 /// <summary> | |
366 /// Requests the bus type, such as PCIBus or PCMCIABus. | |
367 /// </summary> | |
368 LegacyBusType = (0x00000014), | |
369 /// <summary> | |
370 /// Requests the legacy bus number of the bus the device is connected to. | |
371 /// </summary> | |
372 BusNumber = (0x00000015), | |
373 /// <summary> | |
374 /// Requests the name of the enumerator for the device, such as "USB". | |
375 /// </summary> | |
376 EnumeratorName = (0x00000016), | |
377 DevType = 0x00000019, | |
378 Exclusive = 0x0000001A, | |
379 Characteristics = 0x0000001B, | |
380 /// <summary> | |
381 /// Requests the address of the device on the bus. | |
382 /// </summary> | |
383 Address = (0x0000001C), | |
384 /// <summary> | |
385 /// (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. | |
386 /// </summary> | |
387 RemovalPolicy = (0x0000001F), | |
388 /// <summary> | |
389 /// Windows XP and later.) Requests the device's installation state. | |
390 /// </summary> | |
391 InstallState = (0x00000022), | |
392 /// <summary> | |
393 /// Device Location Paths (R) | |
394 /// </summary> | |
395 LocationPaths = (0x00000023), | |
396 } | |
397 public enum CMRDP : uint { | |
398 DEVICEDESC = 0x00000001, | |
399 HARDWAREID = 0x00000002, | |
400 COMPATIBLEIDS = 0x00000003, | |
401 SERVICE = 0x00000005, | |
402 CLASS = 0x00000008, | |
403 CLASSGUID = 0x00000009, | |
404 DRIVER = 0x0000000A, | |
405 CONFIGFLAGS = 0x0000000B, | |
406 MFG = 0x0000000C, | |
407 FRIENDLYNAME = 0x0000000D, | |
408 LOCATION_INFORMATION = 0x0000000E, | |
409 PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000F, | |
410 CAPABILITIES = 0x00000010, | |
411 UI_NUMBER = 0x00000011, | |
412 UPPERFILTERS = 0x00000012, | |
413 LOWERFILTERS = 0x00000013, | |
414 BUSTYPEGUID = 0x00000014, | |
415 LEGACYBUSTYPE = 0x00000015, | |
416 BUSNUMBER = 0x00000016, | |
417 ENUMERATOR_NAME = 0x00000017, | |
63
309c705d7460
Updates and cleanup in Windows USB enumeration code
Ivo Smits <Ivo@UCIS.nl>
parents:
50
diff
changeset
|
418 ADDRESS = 0x0000001D, |
21 | 419 } |
63
309c705d7460
Updates and cleanup in Windows USB enumeration code
Ivo Smits <Ivo@UCIS.nl>
parents:
50
diff
changeset
|
420 } |