WMI, Win32_Processor, and Vista/XP-SP3

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
So, I think this qualifies as interesting. A few years back I wrote a widget for Konfabulator, which later became Yahoo Widgets. The widget is a multi-cpu load monitor. The architecture is basically: Widget javascript calls ATL control which uses a WMI refresher class to grab CPU load via the Win32_Processor object. It all worked great, and the widget, called CPUSpy, got some good buzz.

Then came XP-SP3 and Vista, and the widget stopped working. Instead of showing a separate load bar for each CPU it now showed one load bar, regardless. I didn't dig into it for a long while, because I just haven't had the time and don't use Yahoo Widgets anymore. Last night, in response to email pleas from users, I started to debug on Vista. What I found is that now I have just one Win32_Processor instance on my system, whereas before there was one for each physical CPU or core. The object also has two new properties: NumberOfCores, and NumberOfLogicalProcessors.

I haven't been able to find any documentation yet, but I'm guessing they decided there should be one instance of Win32_Processor for each physical CPU, and then one "logical" processor for each core or hyperthreading thingamajig. The problem is there doesn't seem to be a "Win32_LogicalProcessor" object from which to query load numbers for a given core on a multicore die. So I will have to find some other way to get these numbers if I want to make the widget work again. Seems like a pretty significant change to go undocumented too, so I am still hoping to find some official explanation and work around. I didn't see it referenced in the list of fixes for XP SP3.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Yeah, good find, although it doesn't help much. Guess they are saying what I said in the OP: getting two instances of Win32_Processor for dual core machines in XP prior to SP3 was incorrect behavior. Now the question is: how the heck do you get load numbers for individual cores?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
That looks like it will do the trick, hg403. Thanks a lot for the tip! I remember looking at this class when I first wrote the widget, but for some reason I didn't use it. Will definitely take another look at it.