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. Catch USB-Events

Catch USB-Events

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • B Offline
    B Offline
    BruteF0rce
    wrote on last edited by
    #1

    Hello! I want to catch events on the usb, like "the user plugged in a hid" :) I tried the WM_DEVICECHANGE, but this one helps only with USB-Sticks. Is there a way to get this information? Thank You

    D 1 Reply Last reply
    0
    • B BruteF0rce

      Hello! I want to catch events on the usb, like "the user plugged in a hid" :) I tried the WM_DEVICECHANGE, but this one helps only with USB-Sticks. Is there a way to get this information? Thank You

      D Offline
      D Offline
      Dr Russell
      wrote on last edited by
      #2

      Set the GUID ( DEV_BROADCAST_DEVICEINTERFACE.dbcc_classguid ) to the class of devices that you want to monitor. That will take some digging on your part to discover the proper GUIDs DEV_BROADCAST_DEVICEINTERFACE devBroadcastDeviceInterface; ZeroMemory( &devBroadcastDeviceInterface, sizeof( devBroadcastDeviceInterface )); devBroadcastDeviceInterface.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); devBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; devBroadcastDeviceInterface.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;//GUID_DEVINTERFACE_HID m_hDevNotify = RegisterDeviceNotification ( g_hWnd, &devBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE );

      R 1 Reply Last reply
      0
      • D Dr Russell

        Set the GUID ( DEV_BROADCAST_DEVICEINTERFACE.dbcc_classguid ) to the class of devices that you want to monitor. That will take some digging on your part to discover the proper GUIDs DEV_BROADCAST_DEVICEINTERFACE devBroadcastDeviceInterface; ZeroMemory( &devBroadcastDeviceInterface, sizeof( devBroadcastDeviceInterface )); devBroadcastDeviceInterface.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); devBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; devBroadcastDeviceInterface.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;//GUID_DEVINTERFACE_HID m_hDevNotify = RegisterDeviceNotification ( g_hWnd, &devBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE );

        R Offline
        R Offline
        Requiem Sollar
        wrote on last edited by
        #3

        Good answer for the use case. I used static /*const*/ GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } }; However if I wanted to detect a user inserting/removing a card from a usb card reader... any one? Currently i only know if the carder reader is plugged/unplugged... not if the card is inserted / removed

        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