How can I detect when an SD card is plugged in?
Asked Answered
E

4

6

I'm writing a PC application in C++ that needs to detect when a user connects an SD card to his/her computer. I know how to detect when the card reader is connected, but I do not know how to detect when individual cards are connected/removed.

Does Windows have an IO interface to detect arrival/removal of SD cards?

[Update] the WM_DEVICECHANGE technique that was suggested works only for detecting when an SD Card reader is plugged in. It does not detect when individual cards are inserted into the card reader.

Eastnortheast answered 24/2, 2009 at 21:3 Comment(0)
S
2

Think this is what you need:

http://www.codeproject.com/KB/dotnet/devicevolumemonitor.aspx

Svelte answered 24/2, 2009 at 21:22 Comment(0)
C
1

WM_DEVICECHANGE might be your answer. Here is an example with CDROM.

Clod answered 24/2, 2009 at 21:25 Comment(0)
S
1

check the messages from WM_DEVICECHANGE here is an example

Sourdough answered 24/2, 2009 at 21:31 Comment(0)
L
0

Look at the Windows Portable Devices API, it has functionality that allows you to attach it to an SD reader (it's known as a storage device) and get events when a card is inserted or removed.

It just has two (possibly major) drawbacks:

  • It requires Windows Vista or later
  • It only has a COM API, so if you want to use it from a .NET program you either have a lot of interop ahead of you, or you have to write a wrapper in C++ or C++/CLI
Legislation answered 1/4, 2009 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.