|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Does anyone know of a COM method of obtaining the CPU information (brand [intel/amd],speed, dual core, etc)? I have a method for getting the OS information. Now, I'd like to get the CPU information without need of a DLL. And I'd like something that works regardless of Windows OS (or at least checks OS to determine how to do the COM).
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
While I haven't checked this out myself, I believe moo script - no more moo.dll! v3.13 does what you're looking for.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Windows 2000 (? I think) and later has something called 'WMI', which you can query using COM for all kinds of information. The main downside to it is that it's very slow. I'm not sure if this is mIRC's implementation or WMI, but you'd be better off using a dll. Anyway, since you asked for $com: alias procinfo {
var %a = a $+ $ticks, %b = b $+ $ticks
.comopen %a WBemScripting.SWBemLocator
if (!$com(%a)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
.comclose %a $com(%a,ConnectServer,1,dispatch* %b)
if (!$com(%b)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
.comclose %b $com(%b,ExecQuery,1,bstr,SELECT * FROM Win32_Processor,dispatch* %a)
if (!$com(%a)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
var %i = 1, %n = $comval(%a,0)
while (%i <= %n) {
echo -a Caption: $comval(%a,%i,Caption)
echo -a Manufacturer: $comval(%a,%i,Manufacturer)
echo -a MaxClockSpeed: $comval(%a,%i,MaxClockSpeed)
echo -a Name: $comval(%a,%i,Name)
echo -a NumberOfCores: $comval(%a,%i,NumberOfCores)
echo -a ProcessorType: $comval(%a,%i,ProcessorType)
echo -a Version: $comval(%a,%i,Version)
if (%i < %n) { linesep -a }
inc %i
}
.comclose %a
} The "NumberOfCores" bit returns nothing on my computer, but it's documented so it might work on yours or on computers that are actually dual core. As far as I know WMI can be installed on older computers from the Microsoft website, it just doesn't come with windows.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Thanks, hixxy. That works great. I can use the old method for anyone who doesn't have WMI and the new method for those who do. And I have it set up so the speed isn't an issue at all.
Btw, where do you find all of the COM information? It is hard to find information using COM for specific tasks.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
WMI reference. There are other potentially useful pages on MSDN about WMI, like this scripting primer.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Just a note. After you've decided which kind of information you want to grab, you can speed up the script by only SELECTing the information you want when you query WMI, instead of using * To show this using the code I gave you: alias procinfo {
var %a = a $+ $ticks, %b = b $+ $ticks
.comopen %a WBemScripting.SWBemLocator
if (!$com(%a)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
.comclose %a $com(%a,ConnectServer,1,dispatch* %b)
if (!$com(%b)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
var %query = SELECT Caption,Manufacturer,MaxClockSpeed,Name,NumberOfCores,ProcessorType,Version FROM Win32_Processor
.comclose %b $com(%b,ExecQuery,1,bstr,%query,dispatch* %a)
if (!$com(%a)) {
echo -abcfilqrt info * /procinfo: problem connecting to WMI.
return
}
var %i = 1, %n = $comval(%a,0)
while (%i <= %n) {
echo -a Caption: $comval(%a,%i,Caption)
echo -a Manufacturer: $comval(%a,%i,Manufacturer)
echo -a MaxClockSpeed: $comval(%a,%i,MaxClockSpeed)
echo -a Name: $comval(%a,%i,Name)
echo -a NumberOfCores: $comval(%a,%i,NumberOfCores)
echo -a ProcessorType: $comval(%a,%i,ProcessorType)
echo -a Version: $comval(%a,%i,Version)
if (%i < %n) { linesep -a }
inc %i
}
.comclose %a
} The difference is these two lines: var %query = SELECT Caption,Manufacturer,MaxClockSpeed,Name,NumberOfCores,ProcessorType,Version FROM Win32_Processor
.comclose %b $com(%b,ExecQuery,1,bstr,%query,dispatch* %a) It only SELECTs the information we need, rather than everything.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Thanks for the information.  EDIT: Is it possible with the specific SELECT command to deal with $null items? If the dualcore number is blank (for those who don't have dual core), it doesn't work because %n = $comval(%a,0) evals to 0. It works fine if you use * in the SELECT, but not if you list an item that has a $null value.
Last edited by Riamus2; 07/06/07 12:09 AM.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Nevermind about the $null... I figured that out. Though I do have another question now that I'm learning COM.
Why can't I get information from certain Classes? For example, I can't get any information out of Win32_VideoConfiguration, but I can out of Win32_VideoController. I know that certain values are only available to certain versions of Windows, or don't have data depending on the hardware/software. But I can't get *any* data out of that and I'm on XP.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
It's not available Win32_VideoConfigurationThe Win32_VideoConfiguration WMI class represents a configuration of a video subsystem. Warning This class has been eliminated from Windows XP and later; attempts to use it will generate a fatal error. In place of this class, you should use the properties contained in the Win32_VideoController, Win32_DesktopMonitor, and CIM_VideoControllerResolution classes. BTW: The "NumberOfCores" property referred to above is not available before Vista.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Ah, I missed that message. Thanks.
As for the cores, yes, I saw that and the script is set up to deal with that properly.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|