Page 1 of 1

getSystemInfo API to obtain Processor description

Posted: Fri Aug 07, 2009 2:51 pm
by ConvertFromOldNGs
by Andrew >> Fri, 23 Jul 2004 0:39:45 GMT

I'm looking for a way to obtain this sort of information:

"Processor x86 Family 6 Model 8 Stepping 1 AuthenticAMD ~1990 Mhz "

or even just

"AMD 1.9Ghz"

I'm currently using (GetSystemInfo in kernel32) but am struggling to interpret parts of the structure returned.

Any suggestions would be most welcome.

Re: getSystemInfo API to obtain Processor description

Posted: Fri Aug 07, 2009 2:51 pm
by ConvertFromOldNGs
by Allistar Melville >> Fri, 23 Jul 2004 1:30:40 GMT

Hi Andrew,
You can get some of that information from this key in the registry:

HKEY_LOCAL_MACHINE/Hardware/Description/System/CentralProcessor/0

There is an application called cpuz.exe (you should be able to google for this) which can be executed like this:

cpuz -file=cpu.html

This outputs quite a detailed file in html format (which you'll have to parse in JADE, but that should be relatively easy). This contains quite a bit of information, including everything you wanted and more. From what I know this gets most of it's information from the BIOS.

I hope this helps,
Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

Re: getSystemInfo API to obtain Processor description

Posted: Fri Aug 07, 2009 2:51 pm
by ConvertFromOldNGs
by Allistar Melville >> Fri, 23 Jul 2004 1:32:08 GMT

Sorry to reply to me own post, but you'll find information about getSystemInfo at:
http://msdn.microsoft.com/library/defau ... mation.asp

Regards,
Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

Re: getSystemInfo API to obtain Processor description

Posted: Fri Aug 07, 2009 2:51 pm
by ConvertFromOldNGs
by Andrew >> Mon, 26 Jul 2004 1:35:00 GMT

Thanks Allistar, the "cpuz" option sounds ideal.

I do actually make use of getSystemInfo, it's just that there are a couple of sections within the structure that I can't make sense of.

Re: getSystemInfo API to obtain Processor description

Posted: Fri Aug 07, 2009 2:51 pm
by ConvertFromOldNGs
by Fred >> Mon, 26 Jul 2004 22:21:09 GMT

Andrew
Try this JADE code - 2 JadeScripts using external functions

getSystemInfo(b : Binary [ 36 ] io) is GetSystemInfo in kernel32;

regOpen(hKey:Integer; sKey:String [256]; result:Integer output) :Integer is RegOpenKeyA in advapi32;

regQuery(hKey : Integer;
sKey : String [256] io;
reserved : Integer;
type : Integer;
data : Binary [256] io;
length : Integer io) :Integer is RegQueryValueExA in advapi32;

regClose(hKey:Integer) :Integer is RegCloseKey in advapi32;

getSystemInfo();
constants
PROCESSOR_INTEL_386 : Integer = 386;
PROCESSOR_INTEL_486 : Integer = 486;
PROCESSOR_INTEL_PENTIUM : Integer = 586;
PROCESSOR_MIPS_R4000 : Integer = 4000;
PROCESSOR_ALPHA_21064 : Integer = 21064;
vars
sysInfoStructure : Binary;
dwOemID : Integer;
dwPageSize : Integer;
lpMinimumApplicationAddress : Integer;
lpMaximumApplicationAddress : Integer;
dwActiveProcessorMask : Integer;
dwNumberOrfProcessors : Integer;
dwProcessorType : Integer;
dwAllocationGranularity : Integer;
dwReserved : Integer;

begin
sysInfoStructure [ 32 : 1 ] := 0.Binary;
call getSystemInfo(sysInfoStructure);
dwOemID := sysInfoStructure[ 1 : 4].Integer; dwPageSize := sysInfoStructure[ 5 : 4].Integer; lpMinimumApplicationAddress := sysInfoStructure[ 9 : 4].Integer; lpMaximumApplicationAddress := sysInfoStructure[ 13 : 4].Integer; dwActiveProcessorMask := sysInfoStructure[ 17 : 4].Integer; dwNumberOrfProcessors := sysInfoStructure[ 21 : 4].Integer; dwProcessorType := sysInfoStructure[ 25 : 4].Integer; dwAllocationGranularity := sysInfoStructure[ 29 : 4].Integer;
write dwOemID;
write dwPageSize;
write lpMinimumApplicationAddress;
write lpMaximumApplicationAddress;
write 'ActiveProcessorMask - ' & dwActiveProcessorMask.String;
write 'NumberOrfProcessors - ' & dwNumberOrfProcessors.String;
write 'ProcessorType ' & dwProcessorType.String;
write dwAllocationGranularity;
end;

getStuffFromRegistery();

constants

HKEY_CLASSES_ROOT : Integer = #80000000;
HKEY_CURRENT_USER : Integer = #80000001;
HKEY_LOCAL_MACHINE : Integer = #80000002;
HKEY_USERS : Integer = #80000003;
HKEY_PERFORMANCE_DATA : Integer = #80000004;
HKEY_CURRENT_CONFIG : Integer = #80000005;
HKEY_DYN_DATA : Integer = #80000006;

vars

hKey : Integer;
subKey : String [ 256 ];
valueName : String [ 256 ];
data : Binary [ 256 ];
openKey : Integer;
result : Integer;
openResult : Integer;
length : Integer;

begin

hKey := HKEY_LOCAL_MACHINE;
subKey [ 256 : 1 ] := '';
subKey := 'HARDWARE\DESCRIPTION\System\CentralProcessor\0';
openResult := call regOpen( hKey, subKey, openKey);

data [ 255 : 1] := 0.Binary;
length := 255;
valueName [ 256 : 1] := '';
valueName := '~MHz';

result := call regQuery(openKey, valueName, null, null, data, length);
write 'Mega Hertzs - ' & data.Binary [ 1 : 4].Integer.String;

result := call regClose( openKey );

end;