473,468 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

list of physical disks

Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you

Oct 22 '08 #1
5 16073
"Alex K." <Al***@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
How do I get the list of all physical disks attached to my computer,
similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a
You can use WMI. See this project:
http://www.codeproject.com/KB/cs/har..._serialno.aspx

Or you can use the DeviceIoControl API. You can get some inspiration at
the following link:
http://www.codeproject.com/KB/mcpp/DriveInfoEx.aspx

Oct 22 '08 #2
On Wed, 22 Oct 2008 12:26:41 -0700, Alex K.
<Al***@discussions.microsoft.comwrote:
>Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you
You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();

Unfortunately, you cannot get the Drive Manufacturer and Model.
Oct 22 '08 #3
Joe,

GetDrives gives list of logical drives, not physical disks. E.g. if you have
5 partitions on a single disk GetDrives will give you 5 DriveInfo items. I
need a list of physical disks -- same as in Device Manager | Disk drives
subtree.

Thank you

"Joe Cool" wrote:
On Wed, 22 Oct 2008 12:26:41 -0700, Alex K.
<Al***@discussions.microsoft.comwrote:
Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you

You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();

Unfortunately, you cannot get the Drive Manufacturer and Model.
Oct 23 '08 #4
Hi all,

you should use the Windows Management Interface (WMI). I know, it is only
a VB Page, but have a look here:
http://www.aspfree.com/c/a/Windows-S...sual-BasicNET/
http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx

The available properties are quite numerous.

Cheers,
Steffen
Joe,

GetDrives gives list of logical drives, not physical disks. E.g. if
you have 5 partitions on a single disk GetDrives will give you 5
DriveInfo items. I need a list of physical disks -- same as in Device
Manager | Disk drives subtree.

Thank you

"Joe Cool" wrote:
>On Wed, 22 Oct 2008 12:26:41 -0700, Alex K.
<Al***@discussions.microsoft.comwrote:
>>Hi all

How do I get the list of all physical disks attached to my computer,
similar to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a
Thank you
You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;
foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();
Unfortunately, you cannot get the Drive Manufacturer and Model.

Oct 23 '08 #5
Alex K. wrote:
GetDrives gives list of logical drives, not physical disks. E.g. if you have
5 partitions on a single disk GetDrives will give you 5 DriveInfo items. I
need a list of physical disks -- same as in Device Manager | Disk drives
subtree.
Try and see what this prints:

WqlObjectQuery q = new WqlObjectQuery("SELECT * FROM
Win32_DiskDrive");
ManagementObjectSearcher res = new ManagementObjectSearcher(q);
foreach (ManagementObject o in res.Get()) {
Console.WriteLine("Caption = " + o["Caption"]);
Console.WriteLine("DeviceID = " + o["DeviceID"]);
Console.WriteLine("Decsription = " + o["Description"]);
Console.WriteLine("Manufacturer = " + o["Manufacturer"]);
Console.WriteLine("MediaType = " + o["MediaType"]);
Console.WriteLine("Model = " + o["Model"]);
Console.WriteLine("Name = " + o["Name"]);
// only Vista & 2008: //Console.WriteLine("SerialNumber = "
+ o["SerialNumber"]);
}

Arne
Oct 26 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: robswin | last post by:
I'm working on a storage subsystem test solution and am looking for a way to manage disks as they appear to windows (physical disks, showing up as WMI class entries of type Win32_DiskDrive). I need...
5
by: rc | last post by:
Hi We run SQL 2000 on Windows 2000. The database has one big table with approx. 90m rows in it, it also as 4 indexes on it, one of them is a clustered index. They physical size of the database...
5
by: Mark Kirkwood | last post by:
Dear all, Here is the first installment concerning ATA disks and RAID controller use in a database server. I happened to have a Solaris system to myself this week, so took the opportunity to use...
12
by: Nobody | last post by:
DB2 500G database, Wintel, heavily loaded OLTP (5M+ transactions a day; all transactions are extremely small, all selects are controlled (no ad-hoc), 99% of all selects are very small (no table...
7
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
0
by: Alstersjo | last post by:
Hi Does anybody know how to recieve a list of disks on an remote server. I also want to recieve information about total space and free space.
8
by: vishnu | last post by:
Hi, How do we count the total physical disks assigned to a DB2 database on a RAID 5, solaris environment. Thank you.
3
by: peanutbuttercravings | last post by:
I don't know much about db2 but I need to move a filesystem from a striped logical volume to raid5? And are there any implications moving the filesystems which hold db2 tables to sharks? Is there...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.