请教OnDeviceChange的问题
答案:2 悬赏:20 手机版
解决时间 2021-02-09 23:40
- 提问者网友:凉末
- 2021-02-08 22:58
请教OnDeviceChange的问题
最佳答案
- 五星知识达人网友:七十二街
- 2021-02-08 23:38
框OnInitDialog添加代码: HDEVNOTIFY hDevNotify; DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_LIST; hDevNotify = RegisterDeviceNotification(this->GetSafeHwnd(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE); if( !hDevNotify ) { MessageBox("注册设备失败"); } GUID_DEVINTERFACE_LIST定义: static const GUID GUID_DEVINTERFACE_LIST = { 0xA5DCBF一0, 0x陆5三0, 0x一一D二, { 0x90, 0x一F, 0x00, 0xC0, 0x四F, 0xB9, 0x5一, 0xED } }
全部回答
- 1楼网友:不如潦草
- 2021-02-09 00:55
在你对话框的oninitdialog中添加如下代码:
hdevnotify hdevnotify;
dev_broadcast_deviceinterface notificationfilter;
zeromemory( ¬ificationfilter, sizeof(notificationfilter) );
notificationfilter.dbcc_size = sizeof(dev_broadcast_deviceinterface);
notificationfilter.dbcc_devicetype = dbt_devtyp_deviceinterface;
notificationfilter.dbcc_classguid = guid_devinterface_list;
hdevnotify = registerdevicenotification(this->getsafehwnd(), ¬ificationfilter, device_notify_window_handle);
if( !hdevnotify )
{
messagebox("注册设备失败");
}
guid_devinterface_list的定义为:
static const guid guid_devinterface_list =
{ 0xa5dcbf10, 0x6530, 0x11d2, { 0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed } };
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯