WMI (Windows®management instrumentation) is powerful, it can query the software and hardware of your computer in the form of database, in its database, keep the latest software information and hardware information at all times, so you can use WMI to detect the CPU frequency , temperature, read the process of Windows ...
This article describes how to use WMI to read the PID and vid codes for USB devices
1. Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
2.
3. Dialogs, Stdctrls, Extctrls,activex, comobj;
4.
5.
6.
7. Procedure Tform1.button2click (Sender:tobject);
8.
9. var
10.
Locator:olevariant;
12.
Wmi:olevariant;
14.
Ret:olevariant;
16.
Enum:ienumvariant;
18.
Tmp:olevariant;
20.
value:cardinal;
22.
Begin;
24.
Locator: = Createoleobject (' WbemScripting.SWbemLocator ');
26.
WMI: = Locator.connectserver ('. ', ', ', ', ');
28.
Ret: = WMI. ExecQuery (' SELECT * from Win32_usbhub ')//here Win32_usbhub for inspection, see table below
30.
31.
32.
enum:= IUnknown (ret._newenum) as ienumvariant;
34.
while (Enum.next (1, Tmp, Value) = S_OK) do
36.
Panax Notoginseng. Begin
38.
If Tmp.name= ' USB Mass Storage Device ' Then
40.
ShowMessage (' The hardware signature of this U disk is ' +tmp.pnpdeviceid ')//tmp a collection of returned data, where Pnpdeviceid is the object in the collection containing the PID and vid codes
42.
A. End;
44.
45.
46.
A. End;
48.
49.
50.
Win32_usbhub is only the tip of the iceberg, and the following are commonly used
52.
53.
54.
"Win32_1394controller",
56.
"Win32_baseboard",
58.
"Win32_Battery",
60.
"Win32_BIOS",
62.
"Win32_bus",
64.
"Win32_CacheMemory",
66.
"Win32_CDROMDrive",
68.
"Win32_currentprobe",
70.
"Win32_DesktopMonitor",
72.
"Win32_DeviceMemoryAddress",
74.
"Win32_DiskDrive",
76.
"Win32_displayconfiguration",
78.
"Win32_displaycontrollerconfiguration",
80.
Bayi. "Win32_DMAChannel",
82.
"Win32_fan",
84.
"Win32_floppycontroller",
86.
"Win32_floppydrive",
88.
"Win32_heatpipe",
90.
"Win32_idecontroller",
92.
"Win32_infrareddevice",
94.
"Win32_IRQResource",
96.
"Win32_Keyboard",
98.
"Win32_memoryarray",
100.
"Win32_memorydevice",
102.
"Win32_motherboarddevice",
104.
"Win32_NetworkAdapter",
106.
"Win32_NetworkAdapterConfiguration",
108.
109. "Win32_onboarddevice",
110.
"Win32_ParallelPort",
112.
113. "Win32_pcmciacontroller",
114.
"Win32_physicalmemory",
116.
117. "Win32_PhysicalMemoryArray",
118.
119. "Win32_pnpentity",
120.
121. "Win32_pointingdevice",
122.
123. "Win32_PortableBattery",
124.
"Win32_portconnector",
126.
127. "Win32_PortResource",
128.
129. "Win32_potsmodem",
130.
131. "Win32_powermanagementevent",
132.
"Win32_Printer",
134.
135. "Win32_PrinterConfiguration",
136.
137. "Win32_PrintJob",
138.
139. "Win32_Processor",
140.
"Win32_refrigeration",
142.
143. "Win32_serialport",
144.
145. "Win32_serialportconfiguration",
146.
147. "Win32_smbiosmemory",
148.
149. "Win32_sounddevice",
150.
151. "Win32_SystemEnclosure",
152.
153. "Win32_systemmemoryresource",
154.
"Win32_systemslot",
156.
157. "Win32_TapeDrive",
158.
159. "Win32_temperatureprobe",
160.
161. "Win32_uninterruptiblepowersupply",
162.
163. "Win32_usbcontroller",
164.
165. "Win32_videoconfiguration",
166.
167. "Win32_VideoController",
168.
169. "Win32_voltageprobe",