site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Laurence Harris from Carbon list made some comments { 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); 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! 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/dmarkman%40mac.com This email sent to dmarkman@mac.com Dmitry Markman _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... so here is the modified code: (specifically I replaced CFStringGetCStringPtr to CFStringGetCString also I replaced kCFStringEncodingMacRoman by CFStringGetSystemEncoding ()) 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); } however I suppose that there is a more elegant way by using some matching facility This email sent to site_archiver@lists.apple.com
participants (1)
-
Dmitry Markman