Does anyone know how can i get CPU name and speed using api on intel mac?
Thanks
How to get info about CPU?
It should be fairly simple to translate the following C code, If you don't mind parsing a string:
What I get is the following output:
Do "man sysctlbyname" for more info....
AIR.
Code: Select all
char* cpu_brand() {
static char buffer[128];
size_t length = sizeof(buffer);
sysctlbyname("machdep.cpu.brand_string", &buffer, &length, NULL, 0);
return buffer;
}
The above should work on both Intel and PPC Mac systems.Intel(R) Core(TM)2 Duo CPU E4600 @ 2.40GHz
Do "man sysctlbyname" for more info....
AIR.
"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.
I tried this but get nothing
[edit] it works [/edit]
[edit] it works [/edit]
Code: Select all
ImportC "/usr/lib/libc.dylib";"/usr/lib/libSystem.B.dylib"
sysctlbyname.l(s.s,*buffer,*length,*null,*null2)
EndImport
*buffer = AllocateMemory(128)
length.l=MemorySize(*buffer)
err.l=sysctlbyname("machdep.cpu.brand_string", *buffer, @length, 0, 0);
MessageRequester(" ",PeekS(*buffer), 0)
Last edited by jack on Fri Apr 10, 2009 11:39 pm, edited 2 times in total.


