get mac serial for hdid
This commit is contained in:
parent
5bdb57a8ba
commit
2509cc5e0b
@ -50,10 +50,31 @@ QString get_hdid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <IOKit/IOKitLib.h>
|
||||||
|
|
||||||
QString get_hdid()
|
QString get_hdid()
|
||||||
{
|
{
|
||||||
//hdids are broken at this point anyways
|
CFStringRef serial;
|
||||||
return "just a mac passing by";
|
char buffer[64] = {0};
|
||||||
|
QString hdid;
|
||||||
|
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
|
||||||
|
IOServiceMatching("IOPlatformExpertDevice"));
|
||||||
|
if (platformExpert)
|
||||||
|
{
|
||||||
|
CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert,
|
||||||
|
CFSTR(kIOPlatformSerialNumberKey),
|
||||||
|
kCFAllocatorDefault, 0);
|
||||||
|
if (serialNumberAsCFString) {
|
||||||
|
serial = (CFStringRef)serialNumberAsCFString;
|
||||||
|
}
|
||||||
|
if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) {
|
||||||
|
hdid = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
IOObjectRelease(platformExpert);
|
||||||
|
}
|
||||||
|
return hdid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user