• Advertisement

Archived

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

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

This topic is 5682 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
Check out other value in that key cuz there are things like ~Mhz and Identifier and name.

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
hi, thanks, my mistake was not inserting a ''&'' beside the speed,

this would be the last one, i couldn''t find the actualy ''Intel Pentium 3'' or something like that? all i can find was, GenuineIntel or x86 family 6 model 8 etc.., so should i just be the one to specify it? ie, if mhz is 800 and
GeniuineIntel, then processor is pentium 3...?

thanks,

Share this post


Link to post
Share on other sites
Look for the ProcessorNameString key. It should contain the processor type, or at least what the manufacturer calls it
You might want to bring up that key location in regedit and see what all is there, pretty interesting.

Always remember, you''''re unique. Just like everyone else.

Share this post


Link to post
Share on other sites
If that information is important to your program you shouldn''t rely on the information found in the Registry. The MHZ value e.g. does not exist on my WinME and Win2k systems, maybe it''s only there on WinXP?

Share this post


Link to post
Share on other sites
alright i won''t settle anymore for a win32 api,

Martee: ei, i tried yours already, kewl, got two erros so i commented it out,

si_win.obj : error LNK2001: unresolved external symbol "char * * siOsNames" (?siOsNames@@3PAPADA)

and

error C2556: ''siString siGetLastError(void)'' : overloaded function differs only by return type from ''const char *siGetLastError(void)''

error C2373: ''siGetLastError'' : redefinition; different type modifiers

btw, what is SSE, and err., your code doesn''t have what i want? ie, output ''GenuineIntel Pentium 3'',

Greven: ProcessorNameString? i''ve used that keyword to search on the regedit, no result found?

thanks,

Share this post


Link to post
Share on other sites
Ah, yes ...
I did a few updates to the Linux port (added/changed some functions and variables), but I didn''t update the Windows port yet to reflect the changes. Thanks for reminding me

Right now, it doesn''t actually detect what kind of processor you have (e.g. ''Pentium 3''). It just grabs the vendor string. But I''ll add that soon ...

Share this post


Link to post
Share on other sites
ahh okey,

what is the different between, Major version and minor Version in the OSVERSIONINFO structure? i mean, why did they have to make it like that? ie, declare two variables,?

Share this post


Link to post
Share on other sites

  • Advertisement