简体   繁体   English

如何获得磁盘的标识?

[英]How can I get identity of a disk?

I want to identify disk in c++ in my windows application. 我想在Windows应用程序中以c ++标识磁盘。 For example: I have a disk on E:\\ Then I changed the disk, and replace it with another one. 例如:我在E:\\上有一个磁盘,然后更换了磁盘,并用另一个替换它。 the name is still E:\\ How can I know the disk is changed, it is not the original one? 名称仍然是E:\\我怎么知道磁盘已更改,它不是原始磁盘?

If I have no administrator priority in win7, Can I still use some method to identy different disks? 如果我在win7中没有管理员优先级,是否仍可以使用某些方法来标识不同的磁盘?

Many thanks! 非常感谢!

Probably the relevant methods are: 可能的相关方法是:

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 will give you the serial number. GetVolumeInformation将为您提供序列号。 If this isn't enough you will probably have to resort to WMI_PhysicalMedia . 如果这还不够,您可能不得不诉诸WMI_PhysicalMedia I believe all of this should work without Administrator privileges. 我相信所有这些都应该在没有管理员权限的情况下起作用。

A page listing a bunch of relevant functions is here: http://msdn.microsoft.com/en-us/library/aa365730(v=VS.85).aspx 列出了一系列相关功能的页面在这里: http : //msdn.microsoft.com/zh-cn/library/aa365730(v=VS.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 文件写入期间磁盘已满。 如何获得有关此的通知? - Disk gets full during file write. How can I get notified about this? 如何获得不同操作系统的每个磁盘的recycleBin路径? - How Can I get the recycleBin Path for each disk, for different operation System? 如何编写可以测试磁盘吞吐量的程序? - How can I write a program which can test throughput of disk? 如何获得UNIX中进程的磁盘使用率(IO)? - How do I get the disk usage (IO) of processes in UNIX? 如何以编程方式获取 Linux 中目录的可用磁盘空间 - How do I programmatically get the free disk space for a directory in Linux 如何从整个磁盘中排除一个要挂载的文件 - How can I exclude one file to be mounted from an entire disk 如何在用C ++写入磁盘的程序中实现并行性? - How can I achieve parallelism in a program that is writing to the disk in C++? 如何在Linux上获取磁盘信息? - How to get disk information on Linux? 我可以在用户模式下在 Vista 和 Windows 7 下获得对原始磁盘扇区的写访问权限吗? - Can I get write access to raw disk sectors under Vista and Windows 7 in user mode? 如何从网络逻辑磁盘名称获取物理磁盘索引? - How to get physical disk index from network logical disk name?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM