Discussion:
List Physical Drives (c++ | WINAPI)
(too old to reply)
Alex
2008-04-02 13:16:00 UTC
Permalink
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?


(win32 api, c++)
Kellie Fitton
2008-04-02 14:22:44 UTC
Permalink
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
(win32 api, c++)
Hi,

You can use the following APIs to get the currently available disk
drives on your machine:

GetLogicalDrives()

GetLogicalDriveStrings()

GetDriveType()

http://msdn2.microsoft.com/en-us/library/aa364972.aspx

http://msdn2.microsoft.com/en-us/library/aa364975.aspx

http://msdn2.microsoft.com/en-us/library/aa364939.aspx

Kellie.
Alex
2008-04-02 14:24:00 UTC
Permalink
sorry but i need physical hard drives and not logical...
Sten Westerback (MVP SDK 2005-6 :)
2008-04-02 14:28:50 UTC
Permalink
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
You should tell a bit more specifically what type of information you want.
SCSI ID's?
Anyway, FindFirstVolume() might give you something useful. Or maybe even
FindFirstVolumeMountPoint().
And ofcourse one knows that the physical devices are accessible
(CreateFile()) using paths such as \\.\PHYSICALDRIVE0
Then there is DeviceIoControl with FSCTL_GET_NTFS_VOLUME_DATA and/or
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.

And of course there are PnP related API's but i think they are more
appropriate in kernel mode. But try EnumDeviceDrivers and

If on the other hand you want logical drives, check out GetLogicalDrives().

- Sten
Alex
2008-04-02 14:42:34 UTC
Permalink
Hi,
which information can i obtain with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
coz i need the name of hard drive too))
thanks
Kellie Fitton
2008-04-02 15:46:14 UTC
Permalink
Post by Alex
Hi,
which information can i obtain with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
coz i need the name of hard drive too))
thanks
Hi,

You can use the following WMI class to get the name of the disk
drive manufacturer:

Win32_DiskDrive

http://msdn2.microsoft.com/en-us/library/aa394132(VS.85).aspx

Kellie.
Sebastian G.
2008-04-02 14:30:19 UTC
Permalink
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
Simply enumerate \Device\HarddiskX?
Alex
2008-04-02 14:36:39 UTC
Permalink
Hi,
i have enumerated "PhysicalDriveX" in CreateFile
then i have tested returned value

but i would find a kind of function which gives
number of physical hard drives or handles to physical drive
Christian ASTOR
2008-04-02 16:48:16 UTC
Permalink
Post by Alex
I want to list all physical drives on my machine...
anybody knows how to do this?
(win32 api, c++)
SetupDiGetClassDevs() with &DiskClassGuid -SetupDiEnumDeviceInfo()-
SetupDiGetDeviceRegistryProperty()...
Alex
2008-04-07 07:02:57 UTC
Permalink
Hi
i have a linker when using SetupDi functions
(i work under vs2008) can u help me?
which library contains this functions? :)
Alex
2008-04-07 08:48:36 UTC
Permalink
Hi
i have a linker error when using SetupDi functions
(i work under vs2008) can u help me?
which library contains this functions? :)
Christian ASTOR
2008-04-07 09:01:09 UTC
Permalink
Post by Alex
i have a linker error when using SetupDi functions
(i work under vs2008) can u help me?
which library contains this functions? :)
setupapi.lib
CAHEK
2008-04-08 08:41:03 UTC
Permalink
Hi! could u explain me how can i filter the info coz i want
display just physical drives...
Christian ASTOR
2008-04-08 11:59:22 UTC
Permalink
Post by CAHEK
Hi! could u explain me how can i filter the info coz i want
display just physical drives...
As I said : &DiskClassGuid or &GUID_DEVINTERFACE_DISK

Boris
2008-04-03 05:34:39 UTC
Permalink
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
(win32 api, c++)
WMI: Win32_DiskDrive - just call WMI from C++ - it's just COM API.

Boris
Levis
2008-04-03 06:25:12 UTC
Permalink
Post by Boris
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
(win32 api, c++)
WMI: Win32_DiskDrive - just call WMI from C++ - it's just COM API.
Boris
Always avoid WMI and use the method mentioned above.
It is slow and not installed natively on OS like NT.
Sebastian G.
2008-04-03 09:17:46 UTC
Permalink
Post by Levis
Post by Boris
Post by Alex
Hello!
I want to list all physical drives on my machine...
anybody knows how to do this?
(win32 api, c++)
WMI: Win32_DiskDrive - just call WMI from C++ - it's just COM API.
Boris
Always avoid WMI and use the method mentioned above.
It is slow and not installed natively on OS like NT.
Microsoft says we shouldn't care about NT4- and Win9x/ME any more, but
rather base everything on the Win32 API as in NT5.
Levis
2008-04-03 19:54:17 UTC
Permalink
Post by Sebastian G.
Post by Levis
Always avoid WMI and use the method mentioned above.
It is slow and not installed natively on OS like NT.
Microsoft says we shouldn't care about NT4- and Win9x/ME any more, but
rather base everything on the Win32 API as in NT5.
Customers decide, not Microsoft.
Many are running NT4.
Sten Westerback (MVP SDK 2005-6 :)
2008-04-04 17:02:40 UTC
Permalink
Post by Levis
Post by Sebastian G.
Post by Levis
Always avoid WMI and use the method mentioned above.
It is slow and not installed natively on OS like NT.
Microsoft says we shouldn't care about NT4- and Win9x/ME any more, but
rather base everything on the Win32 API as in NT5.
Customers decide, not Microsoft.
Many are running NT4.
.. and they are stupid as older OS's won't get any hotfixes.... ;)

- Sten
Continue reading on narkive:
Loading...