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?
If I have no administrator priority in win7, Can I still use some method to identy different disks?
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. If this isn't enough you will probably have to resort to 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