Re: USB Device Change Notification
- From: "Sushma" <sushma.yella@xxxxxxxxx>
- Date: 13 Oct 2006 00:13:56 -0700
Hi Philipp,
Thanks for your code. It works now but only question i have now is i
get the arrival/removal notification for my device and the control
enters into DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE statements
also, but it happens to enter more than once when i plugin or remove
the device.
To verify this i put a debug out put message in these statements, the
debug message appears more than once.
Could you tell me why this is happening? Do i need to handle anything
else in my code?
Thank You.
Regards,
Sushma
Philipp Ineichen wrote:
Hi
The following RegisterDeviceNotification function works perfect for me. I
mean I get all Arrival and Removal message for all INPUT devices. I test
it with my Logitech mouse.
BOOL RegisterForDevChange(HWND hDlg, PVOID *hNotifyDevNode)
{
BOOL bRet;
DEV_BROADCAST_DEVICEINTERFACE *pFilterData = new
(DEV_BROADCAST_DEVICEINTERFACE);
ZeroMemory(pFilterData, sizeof(DEV_BROADCAST_DEVICEINTERFACE));
pFilterData->dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
pFilterData->dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
pFilterData->dbcc_classguid = GUID_CLASS_INPUT;
*hNotifyDevNode = RegisterDeviceNotification(hDlg, pFilterData,
DEVICE_NOTIFY_WINDOW_HANDLE);
if(*hNotifyDevNode)
{
bRet = TRUE;
}
else
{
if (pFilterData)
delete (pFilterData);
bRet = FALSE;
}
return bRet;
}
LRESULT CALLBACK MainDlgProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam)
{
:
:
:
case WM_DEVICECHANGE:
switch ((UINT)wParam)
{
case DBT_DEVICEARRIVAL:
SendMessage(hOutputBox, LB_ADDSTRING, 0, (LPARAM)"Device Arrival");
break;
case DBT_DEVICEQUERYREMOVE:
SendMessage(hOutputBox, LB_ADDSTRING, 0, (LPARAM)"Device Query
Remove");
break;
case DBT_DEVICEREMOVECOMPLETE:
SendMessage(hOutputBox, LB_ADDSTRING, 0, (LPARAM)"Device Remove
Complete");
break;
}
break;
:
:
:
}
- PI
--------------------
Philipp Ineichen
www.skagitsystems.ch
.
- Follow-Ups:
- Re: USB Device Change Notification
- From: Nyamagoud
- Re: USB Device Change Notification
- From: hs2
- Re: USB Device Change Notification
- References:
- USB Device Change Notification
- From: Sushma
- Re: USB Device Change Notification
- From: Philipp Ineichen
- USB Device Change Notification
- Prev by Date: Re: NDIS5.1 driver in Vista
- Next by Date: Re: USB Device Change Notification
- Previous by thread: Re: USB Device Change Notification
- Next by thread: Re: USB Device Change Notification
- Index(es):
Relevant Pages
|