Delphi calls WMI to read the PID and vid of the USB device

Source: Internet
Author: User

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 ",

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.