Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mickey

how to get the processor type and speed of the user?

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i tried the GetSystemInfo(...) but can''t seem to figure out the way there, i would like to use a Win32API for this, thanks!!

Share this post


Link to post
Share on other sites
Advertisement
There is no system property for speed, you''re going to have to write a program to measure it (run something like DXDiag, will give your CPU speed within a few mhz).

Share this post


Link to post
Share on other sites
You can find a name in the registry under HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\VendorIdentifier. It is a string and contains GenuineIntel (no space) for Intel and AuthenticAMD (again no space) AMD. There are seeral other codes that you can find on the net. It is easier than using CPUID.

Share this post


Link to post
Share on other sites
quote:
Original post by Puzzler183
Check out other value in that key cuz there are things like ~Mhz and Identifier and name.


On a standard windows machine the information you can find is:

VendorIdentifier (ie. "GenuineIntel")
Identifier (ie. "x86 Family 6 Model 8 Stepping 6")
Update Status (a numeric value)

If you want information on what information is accessable about a processor read this article, ''cuz'' the CPU speed is not something that is reported by the chip, the only way to get the mhz is either 1) through a special program written for your specific motherboard or 2) by making a rough estimation, as programs like DXDiag do. With the right algorithm you can be within a 1-3 mhz of the exact speed.

Share this post


Link to post
Share on other sites

  
DWORD GetCpuSpeed()
{
DWORD dwStartTicks = 0;
DWORD dwEndTicks = 0;
DWORD dwTotalTicks = 0;
DWORD dwCpuSpeed = 0;

// check for high-resolution timer

LARGE_INTEGER qwFrequency = {0};
if(QueryPerformanceFrequency(&qwFrequency) && qwFrequency.QuadPart > 0)
{
LARGE_INTEGER qwStart = {0};
LARGE_INTEGER qwStop = {0};

// 1. step - get start ticks

QueryPerformanceCounter(&qwStart);
for(;;)
{
QueryPerformanceCounter(&qwStop);
if((qwStop.QuadPart - qwStart.QuadPart) * 1000 / qwFrequency.QuadPart > 1)
{
__asm
{
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
_emit 0x0f // CPUID

_emit 0xa2
_emit 0x0f // RDTSC

_emit 0x31
mov [dwStartTicks], eax
}
break;
}
}

qwStart.QuadPart = qwStop.QuadPart;

// 2. step - get end ticks after 1000 ms

for(;;)
{
QueryPerformanceCounter(&qwStop);
if((qwStop.QuadPart - qwStart.QuadPart) / qwFrequency.QuadPart >= 1)
{
__asm
{
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
_emit 0x0f // CPUID

_emit 0xa2
_emit 0x0f // RDTSC

_emit 0x31
mov [dwEndTicks], eax
}
break;
}
}
}
else
{
DWORD dwStart = 0;
DWORD dwStop = 0;

// 1. step - get start ticks

dwStart = GetTickCount();
for(;;)
{
dwStop = GetTickCount();
if((dwStop - dwStart) > 1) // ROLLOVER PAST 1

{
__asm
{
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
_emit 0x0f // CPUID

_emit 0xa2
_emit 0x0f // RDTSC

_emit 0x31
mov [dwStartTicks], eax
}
break;
}
}

dwStart = dwStop;

// 2. step - get end ticks after 1000 ms

for(;;)
{
dwStop = GetTickCount();
if((dwStop - dwStart) >= 1000)
{
__asm
{
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
_emit 0x0f // CPUID

_emit 0xa2
_emit 0x0f // RDTSC

_emit 0x31
mov [dwEndTicks], eax
}
break;
}
}
}

// compute result

dwTotalTicks = dwEndTicks - dwStartTicks;
dwCpuSpeed = dwTotalTicks / 1000000; // MHz


return(dwCpuSpeed);
}


Share this post


Link to post
Share on other sites
Oh I''m sorry Michaelson. If my using "cuz" instead of "because" made the post hard for you to read or you had some other problem, you should have let me know cuz I owuld have changed it for you.

Share this post


Link to post
Share on other sites
thanks guys,

i followed the sample on the MSDN, but i had a problem using the

RegQueryValueEx(hKey,
"~MHZ",
NULL,
NULL,
(LPBYTE)speed,
&dwBufLen);

because MHZ is not a string but a hex number, so how would i go fixin'' this?

Share this post


Link to post
Share on other sites
DWORD Speed;
DWORD Type;
DWORD BufSize = sizeof (DWORD);
RegQueryValueEx(hKey,
"~MHZ",
NULL,
&Type,
(LPBYTE)&Speed,
&BufSize);
ASSERT(Type == REG_DWORD);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!