Depending on exactly what you need, you have several options other than relying on a dying API or brute-force searching through the output of an NSTask. For example, both the NSProcessInfo and the sysctl API can provide a significant amount of information about a system (and, in the case of sysctl, it's pretty portable). If you need even more detailed information there is also IOKit and, using that, you can grab everything down to each individual CPU's ID.

Just the file as "HWInfo.m" and compile it using:

Code:

gcc -framework "Foundation" -framework "IOKit" -o HWInfo HWInfo.m

Edit: Updated with code for grabbing CPUIDs and Serial Number using IOKit
Edit 2: Significantly condensed down the code for grabbing the serial number. It's just grabbing the root entry so setting up a matching dictionary, etc. is just overkill.
Edit 3: Last edit, I promise! Moved the sysctl stuff into its own function to make it a bit easier to parse. Replaced NSLog with objc_println.

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.