如何获取磁盘的标识? [英] How can I get identity of a disk?

查看:148
本文介绍了如何获取磁盘的标识?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Windows应用程序中的c ++标识磁盘。
例如:
我有一个磁盘在E:\
然后我更改了磁盘,并用另一个替换。名称仍然为E:\
如何知道磁盘已更改,它不是原始磁盘?

I want to identify disk in c++ in my windows application. For example: I have a disk on E:\ Then I changed the disk, and replace it with another one. the name is still E:\ How can I know the disk is changed, it is not the original one?

如果我没有管理员优先级win7,我仍然可以使用一些方法来识别不同的磁盘吗?

If I have no administrator priority in win7, Can I still use some method to identy different disks?


推荐答案

可能的相关方法是:

GetLogicalDrives()

BOOL WINAPI GetVolumeInformation(
__in_opt LPCTSTR lpRootPathName,
__out LPTSTR lpVolumeNameBuffer,
__in DWORD nVolumeNameSize,
__out_opt LPDWORD lpVolumeSerialNumber,
__out_opt LPDWORD lpMaximumComponentLength ,
__out_opt LPDWORD lpFileSystemFlags,
__out LPTSTR lpFileSystemNameBuffer,
__in DWORD nFileSystemNameSize

GetDriveType( string vol)

GetVolumeInformation将提供序列号。如果这还不够,您可能需要诉诸 WMI_PhysicalMedia 。我相信所有这一切应该工作没有管理员权限。

GetVolumeInformation will give you the serial number. If this isn't enough you will probably have to resort to WMI_PhysicalMedia. I believe all of this should work without Administrator privileges.

此处列出了一系列相关功能的页面: http://msdn.microsoft.com/en-us/library/aa365730(v = VS.85).aspx

A page listing a bunch of relevant functions is here: http://msdn.microsoft.com/en-us/library/aa365730(v=VS.85).aspx

这篇关于如何获取磁盘的标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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