Re: accessing prom
Re: accessing prom
- Subject: Re: accessing prom
- From: Dmitry Markman <email@hidden>
- Date: Sat, 21 May 2005 23:31:42 -0400
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:
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:
This email sent to email@hidden