ManagementClass Get First Harddrive Only?

Posted on 2006-05-05
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)
Question by:kvnsdr
    LVL 96

    Expert Comment

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

    LVL 1

    Author Comment

    Could not get yours to work.

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

    Accepted Solution

    Closed, 250 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now