91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.93KB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2024-04-26
  • 語(yǔ)言: C#
  • 標(biāo)簽: pid??usb??sb??UI??

資源簡(jiǎn)介

USB讀取PID和UID

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Management;
using?System.Text.Regularexpressions;
using?System.Windows.Forms;

namespace?test
{
????///?
????///?即插即用設(shè)備信息結(jié)構(gòu)
????///?

?????
????public?struct?PnPEntityInfo
????{
????????public?String?PNPDeviceID;??????//?設(shè)備ID
????????public?String?Name;?????????????//?設(shè)備名稱
????????public?String?Description;??????//?設(shè)備描述
????????public?String?Service;??????????//?服務(wù)
????????public?String?Status;???????????//?設(shè)備狀態(tài)
????????public?UInt16?VendorID;?????????//?供應(yīng)商標(biāo)識(shí)
????????public?UInt16?ProductID;????????//?產(chǎn)品編號(hào)?
????????public?Guid?ClassGuid;??????????//?設(shè)備安裝類GUID
????}?
????///?
????///?基于WMI獲取USB設(shè)備信息
????///?

????public?partial?class?USB
????{
????????#region?UsbDevice
????????///?
????????///?獲取所有的USB設(shè)備實(shí)體(過(guò)濾沒(méi)有VID和PID的設(shè)備)
????????///?

????????public?static?PnPEntityInfo[]?AllUsbDevices
????????{
????????????get
????????????{
????????????????return?WhoUsbDevice(UInt16.MinValue?UInt16.MinValue?Guid.Empty);
????????????}
????????}

????????///?
????????///?查詢USB設(shè)備實(shí)體(設(shè)備要求有VID和PID)
????????///?

????????///?供應(yīng)商標(biāo)識(shí),MinValue忽視
????????///?產(chǎn)品編號(hào),MinValue忽視
????????///?設(shè)備安裝類Guid,Empty忽視
????????///?設(shè)備列表

????????public?static??int?numb;//統(tǒng)計(jì)usb設(shè)備數(shù)量??????????
????????public?static?PnPEntityInfo[]?WhoUsbDevice(UInt16?VendorID?UInt16?ProductID?Guid?ClassGuid)
????????{
????????????numb?=?0;

????????????List?UsbDevices?=?new?List();

????????????//?獲取USB控制器及其相關(guān)聯(lián)的設(shè)備實(shí)體
????????????ManagementobjectCollection?USBControllerDeviceCollection?=?new?ManagementobjectSearcher(“SELECT?*?FROM?Win32_USBControllerDevice“).Get();
????????????if?(USBControllerDeviceCollection?!=?null)
????????????{
????????????????foreach?(Managementobject?USBControllerDevice?in?USBControllerDeviceCollection)
????????????????{???//?獲取設(shè)備實(shí)體的DeviceID
????????????????????String?Dependent?=?(USBControllerDevice[“Dependent“]?as?String).Split(new?Char[]?{?‘=‘?})[1];

????????????????????//?過(guò)濾掉沒(méi)有VID和PID的USB設(shè)備
????????????????????Match?match?=?Regex.Match(Dependent?“VID_[0-9|A-F]{4}&PID_[0-9|A-F]{4}“);
????????????????????if?(match.Success)
????????????????????{
????????????????????????UInt16?theVendorID?=?Convert.ToUInt16(match.Value.Substring(4?4)?16);???//?供應(yīng)商標(biāo)識(shí)
????????????????????????if?(VendorID?!=?UInt16.MinValue?&&?VendorID?!=?theVendorID)?continue;

????????????????????????UInt16?theProductID?=?Convert.ToUInt16(match.Value.Substring(13?4)?16);?//?產(chǎn)品編號(hào)
????????????????????????if?(ProductID?!=?UInt16.MinValue?&&?ProductID?!=?theProductID)?continue;

????????????????????????ManagementobjectCollection?PnPEntityCollection?=?new?ManagementobjectSearcher(“SELECT?*?FROM?Win32_PnPEntity?WHERE?DeviceID=“?+?Depend

評(píng)論

共有 條評(píng)論