Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

usb - Eject Memory card from Card Reader C#

I have a custom developed USB card reader. I am using the following code to interact and iterrate over the device:

http://www.codeproject.com/KB/system/usbeject.aspx

The code above provides an 'eject' method using the following line:

Native.CM_Request_Device_Eject_NoUi(device.InstanceHandle, IntPtr.Zero, null, 0, 0);

However this 'eject' method unmounts the entire drive instead of simply ejecting the media card.

Why this is a problem is because I want to 'eject' the media card, then put in a different one. However when the whole reader is ejected i have to unplug/replug the device for it to show back up.

In windows explorer when I right click 'eject' it operates as I am imagining, where it safely removes the memory card but not the card reader.

How can I go about implementing this different type of eject in c#?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'v the same task. :)

You need use ejecting removable media. See c++ sample here: How To Ejecting Removable Media


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...