• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: System serial number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: System serial number (From: Werner Sinnhoefer <email@hidden>)

  • Prev by Date: (10.0.x) option-clicking in statusbar hides active app...
  • Next by Date: Re: Overriding description
  • Previous by thread: Re: System serial number
  • Next by thread: Re: System serial number
  • Index(es):
    • Date
    • Thread