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); }
Requiem Sollar
Posts
-
USB SD Card reader message -
Catch USB-EventsGood 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
-
USB SD Card reader messageTried 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); }
-
What is the easiest way to do a timer ?WM_TIMER This is a very easy thing to use, but is not 100% accurate. You will need SetTimer and KillTimer
-
USB SD Card reader messageWhat 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