USB SD Card reader message
-
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
-
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
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
-
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
If using MFC, u will get notification OnDeviceChange()
-
If using MFC, u will get notification OnDeviceChange()
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
-
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
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); }
-
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
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); }