开发者

How to get 'IOPlatformUUID' on OS X 10.4?

I need to get UUID value on 10.4 but the command seems not to be supported here.

ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'

Above command is working fine on 10.5. Is this not supported on 10.4?

Also I am trying to fetch UUID using below code on 10.4, which is also not working:

void vlm_getSystemU开发者_如何学编程UID_MAC(char * uuid, int bufSize)
{
    io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
    CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
    IOObjectRelease(ioRegistryRoot);
    CFStringGetCString(uuidCf, uuid, bufSize, kCFStringEncodingMacRoman);
    CFRelease(uuidCf);
}

And the above code executes well on 10.5.

Any help would be appreciated.


I believe that the IOPlatformUUID was first added to Mac OS X 10.5 Leopard, and wasn't available in previous versions (someone please correct me if I'm wrong). This blog post hints that this change was added in 10.5.

To ID a Mac running Mac OS X 10.4 and earlier, you'll have to use either the IOPlatformSerialNumber and/or built-in MAC address. See this for details and caveats: http://developer.apple.com/library/mac/#technotes/tn1103/_index.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜