Using WMI to populate Disk Information

  • Thread starter Thread starter Steve Gerhart
  • Start date Start date
S

Steve Gerhart

Hopefully someone can point me in the right direction. I'm try to construct
a table that has the following information about disk drives on 2000 and NT
4.0 boxes.
Size, Partitions and Logical Drive information. I've figured out most of it,
but here's the problem.
The problem that I'm running into is that we have logical drives that have
no drive letter associated with them. WMI doesn't show logical drives that
have no drive letters. We use Mount points and for empty volume nothing at
all. I know that they change WMI in 2003, but I don't have that luxury. Is
there any way to do this, WMI (I'm missing something)remote registry? some
third party component. I'm actually trying to show the same information on a
web page that disk manager shows.

Thanks
Steve Gerhart
 
If I do say, there are a number of volume management API functions you could
PInvoke
to get this information. You mention getting mount points, which is possible
using FindFirstVolumeMountPoint, volumes using FindFirstVolume. There is a
whole lot of stuff available.
 
Justin Rogers said:
If I do say, there are a number of volume management API functions you could
PInvoke
to get this information. You mention getting mount points, which is possible
using FindFirstVolumeMountPoint, volumes using FindFirstVolume. There is a
whole lot of stuff available.

You just have to use System.Management.ManagementObjectSearcher and
System.Management.ObjectQuery to make a "SQL-like" query and retrieve
info from

See that http://www.csharphelp.com/archives2/archive334.html and
Win32_LogicalDisk info on MSDN
 
Justin,

Thanks for the info. I not very familiar with calling windows APIs,
especially the storage API. Can you lead me to an example?
 
Steve Gerhart said:
Justin,

Thanks for the info. I not very familiar with calling windows APIs,
especially the storage API. Can you lead me to an example?

Do you know how to retrieve simple info with WMI in c#?
what are your drives without letter (network disk?) ?
 
I've written the code to gather all the Physical Disks, the partitions, and
the volumes. The volume part is the hard part, becuase I have volumes on
some of our big files servers that are either mount points or they have no
drive letter associated with them. WMI does not gather volume information
unless there are drive letters assoicated with the volume. I'm hoping there
is a way with WMI, but if it comes down to it, I just call some APIs... The
drives that do not have have a drive letter are not network drives. Thanks
 
Steve Gerhart said:
I've written the code to gather all the Physical Disks, the partitions, and
the volumes. The volume part is the hard part, becuase I have volumes on
some of our big files servers that are either mount points or they have no
drive letter associated with them. WMI does not gather volume information
unless there are drive letters assoicated with the volume. I'm hoping there
is a way with WMI, but if it comes down to it, I just call some APIs... The
drives that do not have have a drive letter are not network drives. Thanks

Weird, isn't there any option coz
DriveType have some values try to make a switch/case mode on that value like
switch (Convert.ToInt32(Lecteur["DriveType"]))
{
case 2:
name += "3 1/2 drive";
break;
case 3:
name += Lecteur["VolumeName"].ToString();
break;
case 5:
name += "CD-ROM";
break;
default:
name += Lecteur["Description"].ToString(); -> Maybe you'll have all others here
break;
}
 
Back
Top