以标准用户身份运行程序时如何获取可移动驱动器 [英] How to get removable drive when program is running as standard user

查看:90
本文介绍了以标准用户身份运行程序时如何获取可移动驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了以下文章,并且知道了该程序以管理员身份运行时如何检测可移动驱动器.

如何正确获取USB磁盘的驱动器号 [

I read the article below and know how to detect removable drive when the program is running as administrator.

How To get the usbdisk''s drive letter properly[^]

But there is still a problem and the solution could not detect USB disk when logging as standard users. Could anyone kindly give me how to get removable drive when logging as standard users.

Thanks in advance.

推荐答案

您可以使用GetLogicalDrives获取所有可用的驱动器. 在每个可用逻辑驱动器上使用GetDriveType会告诉您它是否是可移动驱动器.

然后,您可以为WM_DEVICECHANGE消息创建处理程序,以便在插入或拔出可移动驱动器时得到通知.
在此处理程序中,您可以重新枚举逻辑驱动器并查找它们是否可移动.
You can get all available drives using GetLogicalDrives.
Using GetDriveType on each of the available logical drives will tell you if it is a removable drive.

Then you can create a handler for the WM_DEVICECHANGE message so that you''re notified whenever a removable drive is plugged or unplugged.
In this handler you could re-enumerate the logical drives and find if they are removable or not.


这篇关于以标准用户身份运行程序时如何获取可移动驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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