Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessing prom



Laurence Harris  from Carbon list made some comments

so here is the modified code:
(specifically I replaced CFStringGetCStringPtr to CFStringGetCString
also I replaced kCFStringEncodingMacRoman by CFStringGetSystemEncoding ())


{
            Str255              computerSerialNumber;
            CFTypeRef           cfComputerSerialNumber = NULL;
            io_object_t         ioEntry;
            io_iterator_t       ioIterator;
            kern_return_t       kernResult;
            mach_port_t         masterPort;
            bzero(computerSerialNumber,sizeof(computerSerialNumber));
            kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);

if(kernResult == KERN_SUCCESS)
{
kernResult = IORegistryCreateIterator (masterPort,kIOServicePlane,0,&ioIterator);
}
if(kernResult == KERN_SUCCESS)
{
ioEntry = IOIteratorNext(ioIterator);
if(ioEntry != 0)
{
cfComputerSerialNumber = IORegistryEntrySearchCFProperty(ioEntry,kIOServicePlane,CFSTR (kIOPlatformSerialNumberKey),kCFAllocatorDefault,0);
IOObjectRelease(ioEntry);
}
IOObjectRelease(ioIterator);
}
if(cfComputerSerialNumber != NULL)
{
if(CFStringGetTypeID() == CFGetTypeID (cfComputerSerialNumber))
{
Boolean err = CFStringGetCString((CFStringRef) cfComputerSerialNumber,(char *)computerSerialNumber,sizeof (computerSerialNumber),CFStringGetSystemEncoding());
if(!err) bzero(computerSerialNumber,sizeof (computerSerialNumber));
}
CFRelease(cfComputerSerialNumber);
}
printf("S/N: %s\n",(char *)computerSerialNumber);
}


On May 21, 2005, at 11:21 PM, Justin Walker wrote:


On May 21, 2005, at 18:12, Dmitry Markman wrote:


thank you very much Justin

the following code does the job


De nada!


however I suppose that there is a more elegant way by using some matching facility


Could be; elegance is in the eye of the coder, of course...

Cheers,

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
"Weaseling out of things is what separates us from the animals.
 Well, except the weasel."
      - Homer J Simpson
--------

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Dmitry Markman

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >accessing prom (From: Dmitry Markman <email@hidden>)
 >Re: accessing prom (From: Justin Walker <email@hidden>)
 >Re: accessing prom (From: Dmitry Markman <email@hidden>)
 >Re: accessing prom (From: Justin Walker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.