How to get the PhysicalDrive number which the logical drive located?
-
How to get the PhysicalDrive number which the logical drive located? Like how to get the PhysicalDrive number of "C:" logical drive ? Thanks a lot!
Let's roll!
-
How to get the PhysicalDrive number which the logical drive located? Like how to get the PhysicalDrive number of "C:" logical drive ? Thanks a lot!
Let's roll!
HI Dragon, have a look at
Win32_DiskDrive
WMI Class!"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
-
How to get the PhysicalDrive number which the logical drive located? Like how to get the PhysicalDrive number of "C:" logical drive ? Thanks a lot!
Let's roll!
LPTSTR lpVolumeNameBuffer[100]; LPDWORD lpVolumeSerialNumber; LPDWORD lpMaximumComponentLength; LPDWORD lpFileSystemFlags; LPTSTR lpFileSystemNameBuffer[100]; GetVolumeInformation("C:\\",lpVolumeNameBuffer,100,&lpVolumeSerialNumber, lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,100 ); use the above function it returns the Volume Serial Number of the physical C drive . Cheers :)
-
LPTSTR lpVolumeNameBuffer[100]; LPDWORD lpVolumeSerialNumber; LPDWORD lpMaximumComponentLength; LPDWORD lpFileSystemFlags; LPTSTR lpFileSystemNameBuffer[100]; GetVolumeInformation("C:\\",lpVolumeNameBuffer,100,&lpVolumeSerialNumber, lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,100 ); use the above function it returns the Volume Serial Number of the physical C drive . Cheers :)
Hmmm. How about:
TCHAR caVolumeNameBuffer[ 100 ]; DWORD dwVolumeSerialNumber = 0; DWORD dwMaximumComponentLength = 0; DWORD dwFileSystemFlags = 0; TCHAR caFileSystemNameBuffer[ 100 ]; GetVolumeInformation( _T( "C:\\" ), caVolumeNameBuffer, 100, &dwVolumeSerialNumber, &dwMaximumComponentLength, &dwFileSystemFlags, caFileSystemNameBuffer, 100 );
Your example was not passing in valid pointers, only uninitialized ones. Might want to ensure proper termination of theTCHAR
buffers as well. However, I think the OP was asking about the physical device name for the drive, not its serial number; I think they were looking for information such as if a drive is\\.\PhysicalDrive0
or\\.\PhysicalDrive1
, etc. You need that information to open the device itself (the hard drive itself) to do things like send IOCTLs. I do not think that the function you specified will return that information. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
How to get the PhysicalDrive number which the logical drive located? Like how to get the PhysicalDrive number of "C:" logical drive ? Thanks a lot!
Let's roll!
If you need that to do something like send IOCTLs (
DeviceIoControl
), you can also open the device by using the following syntax:\\.\C:
- Open physical device for drive "C"\\.\D:
- Open physical device for drive "D"\\.\A:
- Open physical device for drive "A" I do not know all of the cases where that format and the\\.\PhysicalDrive_**x**_
format are interchangable, but I know you can use it when getting aHANDLE
to use withDeviceIoControl
. Also, not that you are likely to hit it, but there is a bug in older versions of theWin32_DiskDrive
WMI class that limits the number of drives returned. The above method should also work on Windows NT 4.0 versions prior to SP4, but the WMI method will not. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
If you need that to do something like send IOCTLs (
DeviceIoControl
), you can also open the device by using the following syntax:\\.\C:
- Open physical device for drive "C"\\.\D:
- Open physical device for drive "D"\\.\A:
- Open physical device for drive "A" I do not know all of the cases where that format and the\\.\PhysicalDrive_**x**_
format are interchangable, but I know you can use it when getting aHANDLE
to use withDeviceIoControl
. Also, not that you are likely to hit it, but there is a bug in older versions of theWin32_DiskDrive
WMI class that limits the number of drives returned. The above method should also work on Windows NT 4.0 versions prior to SP4, but the WMI method will not. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)Thanks a lot! I just need to use \\.\PhysicalDrivex to open the disk contains the appointed logical volumn. I've lookup in MSDN and found the method. Use DeviceIoControl and send IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS. But MSDN says it can only use in win2000 and later version.
Let's roll!