Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

c - Safely remove a USB drive using the Win32 API?

How do I remove a USB drive using the Win32 API? I do a lot of work on embedded systems and on one of these I have to copy my programs on a USB stick and insert it into the target hardware.

Since I mostly work on the console I don't like to use the mouse and click on the small task-bar icon hundred times a day.

I'd love to write a little program to do exactly that so I can put it into my makefiles, but I haven't found any API call that does the same thing.

Any ideas?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

You can use the CM_Request_Device_Eject() function as well as some other possibilities. Consult the following projects and articles:

DevEject: Straightforward. http://www.withopf.com/tools/deveject/

A useful CodeProject article: http://www.codeproject.com/KB/system/RemoveDriveByLetter.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...