如何获取“IOPlatformUUID”在 OS X 10.4 上?
我需要获取 10.4 上的 UUID 值,但这里似乎不支持该命令。
ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'
上面的命令在 10.5 上运行良好。 10.4 不支持这个吗?
另外,我尝试在 10.4 上使用以下代码获取 UUID,这也不起作用:
void vlm_getSystemUUID_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);
}
并且上述代码在 10.5 上执行良好。
任何帮助将不胜感激。
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_getSystemUUID_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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信
IOPlatformUUID
首先被添加到Mac OS X 10.5 Leopard中,并且在以前的版本中不可用(如果我错了,请纠正我)。 这篇博文暗示此更改是在 10.5 中添加的。要识别运行 Mac OS X 10.4 及更早版本的 Mac,您必须使用
IOPlatformSerialNumber
和/或内置 MAC 地址。有关详细信息和注意事项,请参阅:http://developer.apple.com /library/mac/#technotes/tn1103/_index.htmlI 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