473,587 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ 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 16110
"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:4C******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c omwrote:
>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.GetDr ives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLi ne(di.Name);
Console.WriteLi ne(di.DriveType );
Console.WriteLi ne(di.DriveForm at);
Console.WriteLi ne(di.Available FreeSpace);
Console.WriteLi ne(di.VolumeLab el);
Console.WriteLi ne("");
}
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***@discussi ons.microsoft.c omwrote:
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.GetDr ives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLi ne(di.Name);
Console.WriteLi ne(di.DriveType );
Console.WriteLi ne(di.DriveForm at);
Console.WriteLi ne(di.Available FreeSpace);
Console.WriteLi ne(di.VolumeLab el);
Console.WriteLi ne("");
}
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***@discuss ions.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.GetDr ives();
DriveInfo diDrive;
foreach (DriveInfo di in colDrives)
{
Console.WriteL ine(di.Name);
Console.WriteL ine(di.DriveTyp e);
Console.WriteL ine(di.DriveFor mat);
Console.WriteL ine(di.Availabl eFreeSpace);
Console.WriteL ine(di.VolumeLa bel);
Console.WriteL ine("");
}
Console.ReadKe y();
Unfortunatel y, 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 ");
ManagementObjec tSearcher res = new ManagementObjec tSearcher(q);
foreach (ManagementObje ct o in res.Get()) {
Console.WriteLi ne("Caption = " + o["Caption"]);
Console.WriteLi ne("DeviceID = " + o["DeviceID"]);
Console.WriteLi ne("Decsriptio n = " + o["Descriptio n"]);
Console.WriteLi ne("Manufacture r = " + o["Manufactur er"]);
Console.WriteLi ne("MediaType = " + o["MediaType"]);
Console.WriteLi ne("Model = " + o["Model"]);
Console.WriteLi ne("Name = " + o["Name"]);
// only Vista & 2008: //Console.WriteLi ne("SerialNumbe r = "
+ o["SerialNumb er"]);
}

Arne
Oct 26 '08 #6

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

Similar topics

0
1519
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 to be able to: create partitions on the disks, format the disks, and present them to Windows as a logical disk (drive letter), unpresent them and...
5
1613
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 is approx. 50Gb I am planing to migrate the database to more powerful server. My question is on the new server would we get any benefit from have...
5
2203
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 it as a "control". In this post I used the ATA RAID controller merely to enable UDMA 133 for an oldish x86 machine, the effect of any actual RAID...
12
2859
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 scans, index scans are very limited in size) ). Write performance is generally more important than read performance, read performance of heavy queries...
7
24138
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: StringCollection propNames = new StringCollection(); ManagementClass driveClass = new ManagementClass("Win32_DiskDrive"); PropertyDataCollection props =...
0
255
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
2211
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
3230
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 anything I have to do within db2? This is an aix environment. Thanks a lot.
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2358
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 we have to send another system
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.