开发者

How to get Hardware UUID on windows and mac

I wonder if there is a way to get this info on windows and mac? Like the w开发者_运维技巧ay we can get it on iphone via [[UIDevice currentDevice] uniqueIdentifier]. Thanks in advance!


Be aware that [[UIDevice currentDevice] uniqueIdentifier] is deprecated in iOS , for OS X you can get it from gethostuuid() or the registry e.g.:

+ (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;
}


for windows run mountvol command !


Via Windows Management Instrumentation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜