使用 Win32 API 安全移除 USB 驱动器? [英] Safely remove a USB drive using the Win32 API?

查看:24
本文介绍了使用 Win32 API 安全移除 USB 驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Win32 API 移除 USB 驱动器?我在嵌入式系统上做了很多工作,其中之一我必须将我的程序复制到 U 盘上并将其插入目标硬件.

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.

我很想写一个小程序来做到这一点,这样我就可以把它放到我的 makefile 中,但我还没有发现任何 API 调用可以做同样的事情.

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.

有什么想法吗?

推荐答案

您可以使用 CM_Request_Device_Eject() 函数以及其他一些可能性.参考以下项目和文章:

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

DevEject:直截了当.http://www.withopf.com/tools/deveject/

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

一篇有用的 CodeProject 文章:http://www.codeproject.com/KB/system/RemoveDriveByLetter.aspx

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

这篇关于使用 Win32 API 安全移除 USB 驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆