常用裝置介面類guid
identifier
class guid
guid_devinte***ce_usb_device
guid_devinte***ce_usb_host_controller
guid_devinte***ce_usb_hub
guid_devinte***ce_net
guid_devinte***ce_modem
guid_devinte***ce_disk
guid_devinte***ce_volume
guid_devinte***ce_mediumchanger
guid_devinte***ce_cdrom
guid_devinte***ce_partition
guid_devinte***ce_hid
guid_devinte***ce_keyboard
guid_devinte***ce_mouse
guid_devinte***ce_display_adapter
guid_devinte***ce_image
guid_devinte***ce_monitor
guid_devinte***ce_brightness
guid_devinte***ce_i2c
guid_bthport_device_inte***ce
guid_devinte***ce_comport
guid_devinte***ce_parclass
獲取usb裝置的兩種方式留做筆記,使用時需要獲取對應類的guid去遍歷,可以自行查閱微軟文件。
#include #include #include #include #include #include extern "c"
#pragma comment(lib,"setupapi.lib")
#pragma comment(lib,"hid.lib")
using namespace std;
struct _vid_pid_
bool operator==(const _vid_pid_& other)
return false;
}};std::vector<_vid_pid_> vecvidpid;
//查詢所有vidpid
void hid_findalldevices()
// 獲取裝置詳細資訊資料長度
bret = setupdigetdeviceinte***cedetail(hdevinfo, &stdevdata, null, 0, &length, null);
// 為裝置詳細資訊資料分配記憶體
pdevdetail = (psp_device_inte***ce_detail_data)malloc(length);
if (pdevdetail == null)
// 在devdetail結構中設定cbsize
pdevdetail->cbsize = sizeof(sp_device_inte***ce_detail_data);
// 獲取裝置詳細資訊資料
bret = setupdigetdeviceinte***cedetail(hdevinfo, &stdevdata, pdevdetail, length, null, null);
if (!bret)
/* create file for device read/write */
hdevhandle = createfile(pdevdetail->devicepath,
0,file_share_read | file_share_write,
(lpsecurity_attributes)null,
open_existing,
0,null
);if (hdevhandle == invalid_handle_value)
memset(&stdevattributes, 0x0, sizeof(stdevattributes));
stdevattributes.size = sizeof(stdevattributes);
bret = hidd_getattributes(hdevhandle, &stdevattributes);
if (!bret)
if (find(vecvidpid.begin(), vecvidpid.end(), _vid_pid_(stdevattributes.vendorid, stdevattributes.productid)) == vecvidpid.end())
free(pdevdetail);
pdevdetail = null;
closehandle(hdevhandle);
hdevhandle = null;
} ;// 當不在需要使用setupdigetclassdevs返回的裝置資訊集時,
// 必須呼叫 setupdidestroydeviceinfolist 刪除裝置資訊集
setupdidestroydeviceinfolist(hdevinfo);
return;
}int main()
system("pause");
return 0;
}
#include #include #include #include #include #include #include #include #include #pragma comment(lib,"setupapi.lib")
#pragma comment(lib,"strmiids.lib")
using namespace std;
define_guid(clsid_systemdeviceenum, 0x62be5d10, 0x60eb, 0x11d0, 0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86);
define_guid(guid_devinte***ce_hid, 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30);
//存放裝置的pid vid devid資訊;
typedef struct _devinfo
devinfo, * pdevinfo;
std::vectorg_vecdevinfo;
//獲取所有裝置的pid_vid begin
hresult enumalldevices()
pprobag->release();
}pmoniker->release();
}penummon->release();}}
couninitialize();
return nret;
}int main()
system("pause");
return 0;
}
Windows系統USB轉CDC串列埠驅動限制說明
usb轉串列埠晶元目前主流的幾種usb類別有 1 usb 廠商類 2 usb cdc類 3 usb hid類 其中若使用usb cdc系統內建驅動時,使用時會有諸多特殊性,如下為使用說明 1 測試 現若開啟串列埠狀態下,拔掉usb硬體,然後插上。關閉串列埠後重新開啟一定會出錯,除非再插拔一次硬體才能...
windows 封禁USB介面
windows 封禁usb介面 方法一 隱藏分割槽 執行 regedit進入登錄檔,依次開啟 hkey current user software microsoft windows currentversion policies explorer 在右視窗中新建乙個二進值的鍵值名為 nodrive...
USB 梳理USB子系統
看了很久的usb子系統了,還是霧濛濛的,現在梳理一下。首先從bus入手,在core下面定義了struct bus type usb bus type,這就是usb的bus上的裝置與驅動通用的乙個結構體。首先看driver,api主要在core driver.c裡,註冊usb bus type的,主要...