BelowCodeFrom http://blog.csdn.net/hellogv/, please note the source for reference!
WMI (Windows Management Instrumentation) is very powerful. It can query the software and hardware of your computer in the form of a database, and keep the latest software and hardware information in its database, therefore, you can use WMI to detect CPU clock speed and temperature, and read Windows processes .........
This article describes how to use WMI to read the PID and vid of a USB device.
Windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls, ActiveX, comobj; Procedure plugin (Sender: tobject); varlocator: olevariant; WMI: olevariant; RET: olevariant; Enum: ienumvariant; TMP: olevariant; Value: Cardinal; begin; locator: = createoleobject ('wbemscripting. swbemlocator '); WMI: = locator. connectserver ('. ', ''); RET: = WMI. execquery ('select * From win32_usbhub '); // here, win32_usbhub is the check item. For details, see the table Enum: = iunknown (Ret. _ newenum) as ienumvariant; while (enum. next (1, TMP, value) = s_ OK) dobegin if TMP. name = 'usb mass storage device' then showmessage ('The hardware pattern of this USB flash drive is '+ TMP. pnpdeviceid); // TMP is the collection of returned data. pnpdeviceid is the object in the collection, including the PID and vid code end; win32_usbhub is only the tip of the iceberg, common examples include "win32_1394controller", "win32_baseboard", "win32_battery", "win32_bios", "win32_bus", "temperature", "temperature", "win32_currentprobe", "win32_shorttopmonitor ", "plugin", "win32_diskdrive", "win32_displayconfiguration", "plugin", "plugin", "win32_fan", "win32_floppycontroller", "plugin", "win32_heatpipe", "win32_idecontroller ", "plugin", "win32_irqresource", "win32_keyboard", "win32_memoryarray", "win32_memorydevice", "plugin", "win32_network_adapter", "win32_networkadapterconfiguration", "plugin ", "win32_pcmciacontroller", "temperature", "win32_pointingdevice", "temperature", "win32_portconnector", "win32_portresource", "win32_potsmodem", "temperature ", "win32_printer", "win32_printerconfiguration", "win32_printjob", "win32_processor", "temperature", "win32_serialport", "temperature", "temperature", "win32_sounddevice", "temperature ", "win32_systemmemoryresource", "win32_systemslot", "win32_tapedrive", "plugin", "plugin", "win32_usbcontroller", "win32_videoconfiguration", "win32_videocontroller", "plugin ",