Hello,
I've made a service that *should* detect when a usb flash drive is plugged in. The service does detect something, but I can't retrieve information from the volume. I'm not sure what's wrong, probably the cast.
Here's what I have:
Code://on ServiceMain ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_VOLUME; m_hDevNotify = RegisterDeviceNotification(m_hServiceStatus, &NotificationFilter, DEVICE_NOTIFY_SERVICE_HANDLE);Code:inline void Handler(DWORD dwOpcode,DWORD evtype, PVOID evdata, PVOID Context) { switch (dwOpcode) { ... case SERVICE_CONTROL_DEVICEEVENT: OutputDebugString(L"SERVICE_CONTROL_DEVICEEVENT"); DeviceEventNotify(evtype, evdata); break; ....My function always returns FALSE. I have this code, with some minor modifications working in a simple GUI application. But I need this functionality in a service. :\Code:BOOLEAN DeviceEventNotify(DWORD evtype, PVOID evdata) { if (DBT_DEVICEARRIVAL == evtype || DBT_DEVICEREMOVECOMPLETE == evtype) { DEV_BROADCAST_VOLUME *volume = (DEV_BROADCAST_VOLUME *)evdata; if (volume->dbcv_devicetype != DBT_DEVTYP_VOLUME) { OutputDebugString(L"Not a volume"); return FALSE; }




Reply With Quote