Is there a function to get the Proc. speed? I know where the reg key is stored, but it's not always there on every machine. However 98% of the time I see in the MSINFO32 tool, so they must be getting it from somewhere...
Printable View
Is there a function to get the Proc. speed? I know where the reg key is stored, but it's not always there on every machine. However 98% of the time I see in the MSINFO32 tool, so they must be getting it from somewhere...
What platform do U mean?
For NT-based, U can look at PDH library. It provides access for a lot of information exported by the kernel.
The same access is provided with the hiden registry hive (I cannot recollect its name now).
U can read about it in MSDN. Some samples have place in SDK too.
you can use WMI... Win32_Processor class
http://msdn.microsoft.com/library/de..._processor.asp
Code:instance of Win32_Processor
{
AddressWidth = 32;
Architecture = 0;
Availability = 3;
Caption = "x86 Family 15 Model 2 Stepping 9";
CpuStatus = 1;
CreationClassName = "Win32_Processor";
CurrentClockSpeed = 2392;
CurrentVoltage = 33;
DataWidth = 32;
Description = "x86 Family 15 Model 2 Stepping 9";
DeviceID = "CPU0";
ExtClock = 133;
Family = 2;
L2CacheSize = 0;
Level = 15;
LoadPercentage = 9;
Manufacturer = "GenuineIntel";
MaxClockSpeed = 2392;
Name = " Intel(R) Pentium(R) 4 CPU 2.40GHz";
PowerManagementSupported = FALSE;
ProcessorId = "BFEBF9FF00000F29";
ProcessorType = 3;
Revision = 521;
Role = "CPU";
SocketDesignation = "Microprocessor";
Status = "OK";
StatusInfo = 3;
Stepping = "9";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "FOOBAR";
UpgradeMethod = 6;
Version = "Model 2, Stepping 9";
VoltageCaps = 2;
};
My problem seems to be with 9x based machines, there doesn't seem to be any way to get the speed except for looking at the BIOS on a reboot. That wouldn't be a problem except I can't reboot these machines :) The msinfo32 tool usually just reports something generic like "Genuine Intel Step 2", never the clock speed
You might be correct ;)Quote:
Originally posted by High_D
My problem seems to be with 9x based machines, there doesn't seem to be any way to get the speed except for looking at the BIOS on a reboot. That wouldn't be a problem except I can't reboot these machines :) The msinfo32 tool usually just reports something generic like "Genuine Intel Step 2", never the clock speed
Honestly before you posted your post I quote, I thought of posting http://xaxxon.slackworks.com/rsapi/ for you to reference and to run after those so that I think I can have them feel something for my competition, :D
sigh- That's really like how easy it is to let people see such a stupid psychological reaction of mine.
Regards,
-Vu
Well,
I actually wrote the following attatched file recently for educational purposes. It is really fresh off the press. For Win2k, NT, XP it reads the registry. Whereas for Win9x it simply times the clock straight out in a repeated loop using the Windows tick. The complete testing, especially for Win9x platforms, is still in progress, so there is no guarantee here.
There is a whole bunch of stuff related to the CPU identification and the clock.
It is compatible with VC6, VC.NET and GCC. There are similar samples scattered all over the net but you rarely find parallel support for VC and GCC within the same file.
Take a look at the methods within the project.
Sincerely, Chris.
:)
Did you try Mick's suggestion? Note that you can use a scripting language such as JavaScript to do a quick test to see what you would get using WMI.
I don't recall if win9x returns the processor info, when you install WMI on it. Some of the WIN32 classes under win9x don't return information. Don't have a 9x system to test on. But someone who has WMI installed on a win9x machine could just issue WBEMTEST.exe, enum the root\cimv2 namespace and see if it does...
I have seen WBEMTEST.exe mentioned in my odler version of MSDN but I can't find it to download and I think it is not mentioned in the current MSDN. I assume there is a replacement but I can't find anything saying what the replacement is.
it's shipped with all system??? (well maybe not 9x until you install the WMI subsystem)Quote:
Originally posted by Sam Hobbs
I have seen WBEMTEST.exe mentioned in my odler version of MSDN but I can't find it to download and I think it is not mentioned in the current MSDN. I assume there is a replacement but I can't find anything saying what the replacement is.
%systemroot%\system32\wbem\wbemtest.exe
Yes, it is there. I did search everywhere for it, so I don't know why I could not find it. Maybe a poltergeist in my system.
just count the number of clock cycles in a second and devide by 1,000,000.. of if you want to get fancy you can use mod...
Ahhhh assemble code.. finally...
Code:#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <string.h>
#pragma once
#pragma warning(disable : 4035)
inline unsigned __int64 GetCycleCount(void)
{
_asm _emit 0x0F
_asm _emit 0x31
}
class MyTimer
{
unsigned __int64 m_startcycle;
public:
unsigned __int64 m_overhead;
MyTimer(void)
{
m_overhead = 0;
Start();
m_overhead = Stop();
}
void Start(void)
{
m_startcycle = GetCycleCount();
}
unsigned __int64 Stop(void)
{
return GetCycleCount() - m_startcycle-m_overhead;
}
};
int main()
{
MyTimer timer;
timer.Start(); // take initial reading
Sleep(1000); // wait a second
unsigned cpuspeed10 = (unsigned)(timer.Stop()/100000);
// take the elapsed # of cycles and
// divide by 100,000...
printf("CPU speed %d.%d mhz\n",
cpuspeed10 / 10, cpuspeed10 % 10 );
// divide by 10 more gives you mhz
// the mode gives you the decimal..
return 0;
}
output :
CPU speed 2324.33 mhz
what could be simpler..
Since there was a reference to MSINFO.....Quote:
Originally posted by JMS
what could be simpler..
it depends on what context you place it in, for system management information in a local or distruibuted enviroment, cimv2 (WMI) is simpler.
Mick, why the sour grapes?Quote:
Is there a function to get the Proc. speed?