GestaltAndCocoa
last edited July 29, 2006 01:51:57 (63.249.121.38)
| |
|---|---|
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |
|
I've recently been fidling with Gestalt. I'm looking to capture certain information from my user's machine so they can send me proper bug reports on my software. Gestalt is a Carbon idiom, and has been brought over from the Old Mac days, however it's perfect for what I need.
I'm grabbing the User's OS Version and OS Build information, neither of which require Gestalt. However, Gestalt comes in when I need to grab my User's RAM levels, their Machine's clock speed, and their processor type. Using:
I was able to grab the user's RAM levels. However the Gestalt documentation is not very precise in how it should be implemented for the Processor speed, or the Processor Type. Does anyone know how I might go about implementing this on these two items? They're the last things I need from this application. chris.giddings AT ripplesw.net [updated email address
Try the following:
I get the following on my PowerBook G3:
and this result on my yikes! G4
says DiggoryLaycock Thanks DiggoryLaycock, That helped in every area that I needed.
I get the following on my Mac Mini Intel Core Duo:
The error (-5551 = gestaltUndefSelectorErr) is to be expected, as an Intel CPU obviously won't have PPC features. BTW -- I fixed the error statements to use %d instead of %p, turned all those ifs into else-ifs and made it output the type as the FourCC? it is, not as an int. I also made it more Intel friendly and added some missing constants from the headers. The Gestalt return value is an OSErr? (possible values defined mostly in MacErrors?.h) and that's essentially an int. If others with Intel Macs could chime in and let us know what they get ... Since no Pentium Mac ever shipped, I'm tempted to rename "Intel Pentium" to "Core Duo" or just "Intel Core"... can anyone confirm this would be correct? Also, I think the CPUs? up to the 604 were just "PowerPC 604" and the likes, not "G3 604"... didn't the first G3 ship with a 750? I have a Performa 5300 with a 603something here that definitely wasn't labeled "G3", at least. Not that it would matter much, as no CPU earlier than a G3 officially supports OS X, so we could probably get rid of those constants. If anyone does that, feel free to make this a switch(). -- UliKusterer
Take a look at libkern/sysctl.h which defines hw.optional.xyz that can be used to determine optional processor features instead. -- Chris
Wikipedia (http://en.wikipedia.org/wiki/PowerPC_G3) supports my claim that the 7x0 CPUs? were the first G3s, so I'm changing those. -- UliKusterer
Apple has stated in the Universal Porting Guide that all Intel chips will return a generic value (gestaltCPUPentium, I believe) for the gestaltNativeCPUtype selector. -JonathanGrynspan
Also, these days you should use gestaltPhysicalRAMSizeInMegabytes not gestaltPhysicalRAMSize (to support systems with more than 2 GiB? of RAM). -- smcbride
If you need to get this kind of information programatically you're much better off using the system_profiler tool w/ NSTask. Let it do the heavy lifting for you. system_profiler -xml -detailLevel mini This returns a Plist which you can then turn into objects when you need to with NSPropertyListSerialization?. I replaced the long if/else if chain with a switch anyway. It needed to be done! -Harv | |
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |