Re: System serial number
Re: System serial number
- Subject: Re: System serial number
- From: "Alastair J.Houghton" <email@hidden>
- Date: Tue, 15 Jul 2003 10:49:07 +0100
On Tuesday, July 15, 2003, at 08:43 am, Werner Sinnhoefer wrote:
Hi!
Seems like all Macs have a serial number. You can get it from the
IORegistry. Here is how I pick it up ( and pack it into a string which
will be formated as the one you see in the "About this Mac" dialog):
[snip]
propID = CFGetTypeID(prop);
if (propID == 5) {
You shouldn't be comparing the result of CFGetTypeID() with a constant
like this; the documentation for CFGetTypeID() says:
This function returns a value that uniquely identifies the opaque type
of any Core Foundation object. You can compare this value with the
known
CFTypeID identifier obtained with a "GetTypeID" function specific to a
type, for example CFDateGetTypeID. These values might change from
release
to release or platform to platform.
So if you do (propID == 5), your code may break in future. You should
write
if (propID == CFDataGetTypeID()) {
instead.
Also, on a more general note, you could have used strncpy() to simplify
your code somewhat (by replacing two of your while loops).
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.