Re: How do you get the number of physically installed hard disks (Win32)?

Pashupati,

you wrote on Friday, October 11, 2002, 02:49:22:

PK> In my experience, I have seen the \.\PHYSICALDRIVEN not to be in
PK> sequence, as in from 0 to N-1 especially in SAN environment. For an
PK> example, I have disk being shown as \.\PHYSICALDRIVE15 when there
PK> are just 3 disks. Is there any way to this win32 name from other
PK> win32 name, which you get from interface detail info.

Not that I’m aware of. But why do you need to use \.\PHYSICALDRIVEx at
all if you can open the device by other means, as discussed?

PK> Winobj info is updated for such devices, any clue which calls/data
PK> structures is it using?

WinObj uses the undocumented NtQueryDirectoryObject() API to walk the
object manager name space. Get Gary Nebbetts’s “Native API Reference”
book if you want to go down this path.

Ralf.

why not just use the interface name to open the device?

-p
-----Original Message-----
From: Pashupati Kumar [mailto:xxxxx@legato.com]
Sent: Thursday, October 10, 2002 5:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: How do you get the number of physically installed
hard disks (Win32)?

RB>In my experience the enumeration index of a disk device in either
RB>SetupDiEnumDeviceInterfaces() or SetupDiEnumDeviceInfo() just is it’s

RB>physical drive number. So based on the code I posted, you could also
do
RB>while ( SetupDiEnumDeviceInfo(hDevInfoSet, dwDisks, &DevInfoData) )
RB>{
RB> wsprintf(szDisk, “\\.\PHYSICALDRIVE%d”, dwDisks);
RB> CreateFile(szDisk, …);
RB> dwDisks++;
RB>}
In my experience, I have seen the \.\PHYSICALDRIVEN not to be in
sequence, as in from 0 to N-1 especially in SAN environment. For an
example, I have disk being shown as \.\PHYSICALDRIVE15 when there are
just 3 disks.
Is there any way to this win32 name from other win32 name, which you get
from interface detail info.Winobj info is updated for such devices, any
clue which calls/data structures is it using?
thanks
pashupati

-----Original Message-----
From: Ralf Buschmann [mailto:xxxxx@backmagic.de]
Sent: Thursday, October 10, 2002 2:03 PM
To: NT Developers Interest List
Subject: [ntdev] Re: How do you get the number of physically installed
hard disks (Win32)?

Pashupati,
you wrote on Thursday, October 10, 2002, 20:04:17:
PK> fine. you can get total number of physical drives and also the
PK> interface name (in form guid) by calling another setup API func.
Right, that would be an interface class enumeration calling
SetupDiGetClassDevs() for GUID_DEVINTERFACE_DISK with flag
DIGCF_INTERFACEDEVICE. You the use SetupDiEnumDeviceInterfaces() to
enumerate and can subsequently call SetupDiGetDeviceInterfaceDetail() to

obtain a Win32 device name that you can pass directly to CreateFile() to

obtain a handle to the device.
Take a look at
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q264203 for a
great sample.
PK> Are you aware of any function which can give me indivual device name

PK> in form of \.\PHYSICALDRIVN.
In my experience the enumeration index of a disk device in either
SetupDiEnumDeviceInterfaces() or SetupDiEnumDeviceInfo() just is it’s
physical drive number. So based on the code I posted, you could also do
while ( SetupDiEnumDeviceInfo(hDevInfoSet, dwDisks, &DevInfoData) )
{
wsprintf(szDisk, “\\.\PHYSICALDRIVE%d”, dwDisks);
CreateFile(szDisk, …);
dwDisks++;
}
Ralf.


You are currently subscribed to ntdev as: xxxxx@Legato.COM
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to %%email.unsub%%