Как получить аппаратный UUID в Windows и Mac

#uuid

#uuid

Вопрос:

Интересно, есть ли способ получить эту информацию в Windows и Mac? Похоже на то, как мы можем получить его на iphone через [[UIDevice currentDevice] uniqueIdentifier]. Заранее спасибо!

Ответ №1:

Имейте в виду, что [[UIDevice currentDevice] uniqueIdentifier] устарел в iOS, для 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;
}
  

Ответ №2:

для Windows выполните команду mountvol!

Ответ №3: