使用哪个代码片段来处理USB设备插入
Which code fragment to use to handle USB device insertion?
应用程序可以使用RegisterDeviceNotification函数来注册以接收来自系统的通知消息。这个例子展示了如何注册设备接口的事件通知,这些设备接口是接口类的成员,其GUID传递给函数。
在这个例子中,我应该使用哪个代码片段来处理USB设备插入消息?
搜索DBT_DEVICEARRIVAL:这是USB设备插入消息处理的地方。
case WM_DEVICECHANGE:
{
//
// This is the actual message from the interface via Windows messaging.
// This code includes some additional decoding for this particular device type
// and some common validation checks.
//
// Note that not all devices utilize these optional parameters in the same
// way. Refer to the extended information for your particular device type
// specified by your GUID.
//
PDEV_BROADCAST_DEVICEINTERFACE b = (PDEV_BROADCAST_DEVICEINTERFACE) lParam;
TCHAR strBuff[256];
// Output some messages to the window.
switch (wParam)
{
case DBT_DEVICEARRIVAL:
msgCount++;
StringCchPrintf(
strBuff, 256,
TEXT("Message %d: DBT_DEVICEARRIVALn"), msgCount);
break;
相关文章:
- 警告处理为错误这里有什么问题
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 处理多个异常集合的C++方法
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 使用流处理接收到的数据
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 基于多个条件处理地图中的所有元素
- 如何用数字处理log(0)
- SSL上的`curl_easy_send`和`curl_asy_recv`:如何处理`CURLE_AGAIN`
- 错误处理.将系统错误代码映射到泛型
- 从文本文件中读取时钟时间和事件时间并进行处理
- 是否可以使用winusb同时与多个相同的usb设备进行通信
- 在运行时处理类型擦除的数据-如何不重新发明轮子
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- 用于矢量处理的多个线程
- 对字符串进行排序时,在c++中处理sort()
- 插入或删除时获取usb的dos_name
- 使用哪个代码片段来处理USB设备插入
- 在Linux和Mac上处理可移动媒体USB/CD-ROM装载/umount事件