?
Solved

ManagementClass Get First Harddrive Only?

Posted on 2006-05-05
4
Medium Priority
?
533 Views
Last Modified: 2008-01-09
I'm working with the following typical example of WMI hardware searching, but only need the FIRST harddrive instead of the whole array. The following code is all I can find.

ManagementClass mc = new ManagementClass("Win32_PhysicalMedia");
            foreach (ManagementObject mo in mc.GetInstances())
            {
                if (mo["SerialNumber"] != null)
                    data.DriveSerialNumbers.Add(mo["SerialNumber"].ToString());
            }
0
Comment
Question by:kvnsdr
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16619105
@"Select * From Win32_PhysicalMedia Where Tag = \\.\PHYSICALDRIVE0"

Bob
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 16634240
Could not get yours to work.

This works for me: @"SELECT * FROM Win32_LogicalDisk where DeviceID = 'C:'");
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16676629
Closed, 250 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question