Home > Software engineering >  Consult everybody a great god why OnDeviceChange always received 7?
Consult everybody a great god why OnDeviceChange always received 7?

Time:11-18

Consult everybody a great god why OnDeviceChange always received 7? Equipment has been registered, no prompt registration failed, why only received 7?
//registered part 
UID guid;
Retrieves the hr=CoCreateGuid (& amp; Guid);

//in the notification message dialog initialization process equipment register to the winproc
//Register to receive notification when a USB device is plugged in.
HDEVNOTIFY gNotifyDevHandle;
DEV_BROADCAST_DEVICEINTERFACE broadcastInterface;
BroadcastInterface. Dbcc_size=sizeof (DEV_BROADCAST_DEVICEINTERFACE);
BroadcastInterface. Dbcc_devicetype=DBT_DEVTYP_DEVICEINTERFACE;

Memcpy (& amp; (broadcastInterface. Dbcc_classguid), & amp; (guid), sizeof (struct _GUID));

GNotifyDevHandle=RegisterDeviceNotification (this - & gt; GetSafeHwnd (),
& BroadcastInterface,
DEVICE_NOTIFY_WINDOW_HANDLE);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Afx_msg BOOL OnDeviceChange (UINT nEventType, dwords dwData);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
BEGIN_MESSAGE_MAP (CRFIDInputToolDlg CDialog)
ON_WM_DEVICECHANGE ()
.
END_MESSAGE_MAP ()
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
BOOL CRFIDInputToolDlg: : OnDeviceChange (UINT nEventType, dwords dwData)
{
DwData DEV_BROADCAST_DEVICEINTERFACE * DBD=(DEV_BROADCAST_DEVICEINTERFACE *);

The switch (nEventType)
{
Case DBT_DEVICEREMOVECOMPLETE:
AfxMessageBox (_T (" equipment to remove "));
break;
Case DBT_DEVICEARRIVAL:
AfxMessageBox (_T (" equipment access "));
break;
Default:
break;
}
}

Everybody to help me have a look at where is wrong, thank you

CodePudding user response:

DBT_DEVNODES_CHANGED=0 x0007;

CodePudding user response:

Different equipment & amp; Driver may send message is not the same, can be to enumerate the WM_DEVICECHANGE device to determine changes in

  • Related