我想知道是否有办法在Windows和Mac上获取此信息?就像我们通过[[UIDevice currentDevice] uniqueIdentifier]在iphone上获取它一样。提前谢谢!
答案 0 :(得分:3)
请注意,iOS中不推荐使用[[UIDevice currentDevice] uniqueIdentifier],对于OS X,您可以从gethostuuid()或注册表中获取它,例如:
+ (NSString*)getMachineUUID
{
NSString *ret = nil;
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
if (platformExpert) {
CFTypeRef cfstring = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
if (cfstring) {
ret = [NSString stringWithFormat:@"%@",cfstring];
CFRelease(cfstring);
}
IOObjectRelease(platformExpert);
}
return ret;
}
答案 1 :(得分:1)
for windows 运行mountvol命令!
答案 2 :(得分:0)