Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. win32 service for device detection

win32 service for device detection

Scheduled Pinned Locked Moved C / C++ / MFC
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _T No name
    wrote on last edited by
    #1

    hi i am writing a win 32 service while will detect the USB device when connected. I need to know the name of device which is connected i have written following service handler. VOID WINAPI ServiceHandler(DWORD fdwControl,DWORD evtype, LPVOID evdata, LPVOID Context) { /*DEV_BROADCAST_VOLUME* pDev = (DEV_BROADCAST_VOLUME*)evdata;*/ DEV_BROADCAST_HDR* pHdr = (DEV_BROADCAST_HDR*)evdata; switch(fdwControl) { case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: ProcessStarted = FALSE; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOPPED; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; // terminate all processes started by this service before shutdown { EndProcess(/*i*/0); delete ProcessNames[/*i*/0]; } break; case SERVICE_CONTROL_PAUSE: ServiceStatus.dwCurrentState = SERVICE_PAUSED; break; case SERVICE_CONTROL_CONTINUE: ServiceStatus.dwCurrentState = SERVICE_RUNNING; break; case SERVICE_CONTROL_INTERROGATE: break; case SERVICE_CONTROL_DEVICEEVENT: switch(evtype) { case DBT_DEVICEARRIVAL: //DEV_BROADCAST_VOLUME* pDev = (DEV_BROADCAST_VOLUME*)evdata; if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { DEV_BROADCAST_DEVICEINTERFACE *pDevInt = (DEV_BROADCAST_DEVICEINTERFACE*)evdata; UpdateDevice(pDevInt,(WPARAM)evtype); } break; case DBT_DEVICEREMOVECOMPLETE: //DEV_BROADCAST_VOLUME* pDev = (DEV_BROADCAST_VOLUME*)evdata; if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { DEV_BROADCAST_DEVICEINTERFACE *pDevInt = (DEV_BROADCAST_DEVICEINTERFACE*)evdata; UpdateDevice(pDevInt,(WPARAM)evtype); } break; } break; } in case of DBT_DEVICEARRIVAL the pDevInt i am getting does not contain the dbcc_name string. it only contains "\". Plz help where i am doing wrong thanx in advance

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups