Skip to content

Instantly share code, notes, and snippets.

@serg-z
Last active December 31, 2015 01:09
Show Gist options
  • Select an option

  • Save serg-z/7911612 to your computer and use it in GitHub Desktop.

Select an option

Save serg-z/7911612 to your computer and use it in GitHub Desktop.
UUID on OS X
void get_platform_uuid(char *buf, int bufSize)
{
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
IOObjectRelease(ioRegistryRoot);
CFStringGetCString(uuidCf, buf, bufSize, kCFStringEncodingMacRoman);
CFRelease(uuidCf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment