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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. USB SD Card reader message

USB SD Card reader message

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
6 Posts 4 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.
  • R Offline
    R Offline
    Requiem Sollar
    wrote on last edited by
    #1

    What windows message is created when a SD card is inserted or removed from a USB SD Card reader? I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window. And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there. I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information. OS is XP or 2000 C++ only please, as i am sure .Net has a pretty answer thanks

    M A R 4 Replies Last reply
    0
    • R Requiem Sollar

      What windows message is created when a SD card is inserted or removed from a USB SD Card reader? I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window. And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there. I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information. OS is XP or 2000 C++ only please, as i am sure .Net has a pretty answer thanks

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      IIRC when a CD is inserted/ejected, the system broadcasts a WM_DEVICECHANGE message. Try handling that, it might work the same for cards. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

      1 Reply Last reply
      0
      • R Requiem Sollar

        What windows message is created when a SD card is inserted or removed from a USB SD Card reader? I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window. And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there. I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information. OS is XP or 2000 C++ only please, as i am sure .Net has a pretty answer thanks

        A Offline
        A Offline
        Anilkumar K V
        wrote on last edited by
        #3

        If using MFC, u will get notification OnDeviceChange()

        T 1 Reply Last reply
        0
        • A Anilkumar K V

          If using MFC, u will get notification OnDeviceChange()

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          anilFirst wrote:

          OnDeviceChange()

          Sorry to Point you Sir, OnDeviceChange() is mapped function of WM_DEVICECHANGE only!

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV

          1 Reply Last reply
          0
          • R Requiem Sollar

            What windows message is created when a SD card is inserted or removed from a USB SD Card reader? I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window. And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there. I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information. OS is XP or 2000 C++ only please, as i am sure .Net has a pretty answer thanks

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

            Tried the following... It catches the CD door as a reply said it would... no dice on the SD card reader.... Somebody alse asked the question today in a different thread. Another, less obvious course of action was given. I will repost if that works LRESULT CTestSdcardDlg::WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)//HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { int i = 5; i++; switch (uMsg) { case WM_DEVICECHANGE: // Initialize the window. AfxMessageBox(_T("Test catch")); break; default: break; } return CDialog::WindowProc(uMsg, wParam, lParam); }

            1 Reply Last reply
            0
            • R Requiem Sollar

              What windows message is created when a SD card is inserted or removed from a USB SD Card reader? I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window. And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there. I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information. OS is XP or 2000 C++ only please, as i am sure .Net has a pretty answer thanks

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

              This is an update.... using a different poster's thread answer.... I can now get the insertion and removal of the SD card reader.... I still cannot get the card insertion/removal. Since its frustrating when people do not post full code examples when they are looking help, i will offer this for code for those of you that solely need to detect a USB device insertion/removal, even though it does not do what i need ....... static /*const*/ GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } }; bool CTestSdcardDlg::DoRegNote() { DEV_BROADCAST_DEVICEINTERFACE devInter; ZeroMemory(&devInter, sizeof(devInter)); devInter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); devInter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; devInter.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; if(RegisterDeviceNotification(g_hWnd, &devInter, DEVICE_NOTIFY_WINDOW_HANDLE) == NULL) { int i = GetLastError(); int j = 5; } return true; } LRESULT CTestSdcardDlg::WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)//HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch (uMsg) { case WM_DEVICECHANGE: // Initialize the window. AfxMessageBox(_T("Test catch")); break; default: break; } return CDialog::WindowProc(uMsg, wParam, lParam); }

              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