开发者

How to get Hardware UUID on windows and mac

开发者 https://www.devze.com 2023-02-25 04:21 出处:网络
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 [[U

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

精彩评论

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

关注公众号