Propertly detecting memory slots and memory with WMI?

Posted on 2006-05-12
Last Modified: 2013-12-03
Our Win32 app has successfully detected memory slots and associated memory on machines in the past by using SMBios calls. But we recently moved to using WMI calls.

However, running on newer Dell machines (Dell GX280 with Windows 2003 sp1 for example) are reporting odd,incorrect results.

The machine has 4 memory slots, with 2 containing memory chips, but our results are showing all slots containing memory.

To fetch the slot configuration we first query: select * from win32_memorydevices.
Then for each row returned, we fetch the ASSOCIATORS of the row where the class is Win32_physicalmemory:

CString strQuery = "ASSOCIATORS OF {Win32_MemoryDevice.DeviceID=\"";
                                    strQuery += sMemoryDeviceID;
                                    strQuery += "\"} WHERE ResultClass = Win32_PhysicalMemory";

There must be a problem in our queries. Is these the proper queries to execute to determine the number of slots, and then whether or not each slot has memory in it and how much?

Thanks experts!
Question by:rascal
    LVL 41

    Accepted Solution

    Just curious, what does just the Win32_PhysicalMemory class alone provide?

    using System;
    using System.Management;
    using System.Windows.Forms;

    namespace WMISample
        public class MyWMIQuery
            public static void Main()
                    ManagementObjectSearcher searcher =
                        new ManagementObjectSearcher("root\\CIMV2",
                        "SELECT * FROM Win32_PhysicalMemory");

                    foreach (ManagementObject queryObj in searcher.Get())
                        Console.WriteLine("Win32_PhysicalMemory instance");
                        Console.WriteLine("BankLabel: {0}", queryObj["BankLabel"]);
                        Console.WriteLine("Capacity: {0}", queryObj["Capacity"]);
                        Console.WriteLine("DataWidth: {0}", queryObj["DataWidth"]);
                        Console.WriteLine("DeviceLocator: {0}", queryObj["DeviceLocator"]);
                        Console.WriteLine("FormFactor: {0}", queryObj["FormFactor"]);
                        Console.WriteLine("Speed: {0}", queryObj["Speed"]);
                        Console.WriteLine("TotalWidth: {0}", queryObj["TotalWidth"]);
                        Console.WriteLine("TypeDetail: {0}", queryObj["TypeDetail"]);
                catch (ManagementException e)
                    MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
    LVL 1

    Author Comment

    Hi graye

    I don't have a .net platform handy to run the above, but the equivalent script run in wbemtest showed the 2 sockets in use (out of the 4 on the machine).

    All the fields looked normal, but it was telling that the banklabel was 0 and 2 respectively for the 2 sockets. Seems to lend support to the concept that access or visibility to all 4 sockets is blocked, but the ones that do report do show their proper bank label.

    I wonder if I should just assume that if there is a gap in the reporting of the sockets that I should just "fill in the gaps" since they always have to appear in 2's?

    LVL 41

    Expert Comment


    Perhaps the two pairs of physical "dual port" slots are *supposed* to appear as two logical slots?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
    In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    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…

    730 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

    15 Experts available now in Live!

    Get 1:1 Help Now