Getting system information (was Re: Newbie: My first app, how to?)
Getting system information (was Re: Newbie: My first app, how to?)
- Subject: Getting system information (was Re: Newbie: My first app, how to?)
- From: "M. Uli Kusterer" <email@hidden>
- Date: Thu, 23 Sep 2004 22:46:30 +0200
At 20:58 Uhr -0400 22.09.2004, Chris Garaffa wrote:
I outlined the techniques of my program on my blog:
<http://moondrop.nilzero.com/archives/2004/07/01/getting_system_information_via_cocoa_and_carbon.php>.
Feel free to borrow/steal/whatever-you'll-call-it some of the code
and information. If you'd like the actual source code, I can dig it
up and post it up on my site for you. This will provide you with the
machine type (not guaranteed to be exact - read the post for more
information), serial number, OS version, user name, RAM, CPU speed,
CPU count, HD capacity, and whether AirPort is available.
There are probably better ways to do many of the things I've done,
but that's what I came up with.
Ugh... a lot of that code is horribly wrong (especially the serial
number one from the archives).
For better source code that does this (and a lot of other things), see:
http://www.cocoadev.com/index.pl?HowToGetHardwareAndNetworkInfo
For the system version, here's my function that correctly decodes the
version number:
NSString* UKSystemVersion()
{
long sysVersion;
if( Gestalt( gestaltSystemVersion, &sysVersion ) != noErr )
return nil;
int majorHiNib, majorLoNib, minorNib, bugNib;
majorHiNib = (sysVersion & 0x0000F000) >> 12;
majorLoNib = (sysVersion & 0x00000F00) >> 8;
minorNib = (sysVersion & 0x000000F0) >> 4;
bugNib = sysVersion & 0x0000000F;
if( majorHiNib == 0 )
return [NSString stringWithFormat: @"%ld.%ld.%ld",
majorLoNib, minorNib, bugNib];
else
return [NSString stringWithFormat: @"%ld%ld.%ld.%ld",
majorHiNib, majorLoNib, minorNib, bugNib];
}
And another one that gives you the physical RAM size in Megabytes:
unsigned UKPhysicalRAMSize() // In MBs.
{
long ramSize;
if( Gestalt( gestaltPhysicalRAMSizeInMegabytes, &ramSize ) == noErr )
return ramSize;
else
return 0;
}
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden