Mac license info
Mac license info
In Windows, in registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion there's a "ProductID" string key with value along the lines of "23423412-2312-234234-12423434", which for the most part is unique to each purchased license. I'm just wondering is there something similar on Mac OSX?
Re: Mac license info
have you tried About This Mac/System Report ?
Re: Mac license info
yes i believe its the Serial Number field, but how as a programmer do we access this?
Re: Mac license info
Tested with PB 5.42
Code: Select all
ImportC ""
IOServiceGetMatchingService(masterPort, matching)
IOServiceMatching(name.p-ascii)
EndImport
platformExpert = IOServiceGetMatchingService(#Null, IOServiceMatching("IOPlatformExpertDevice"))
If platformExpert
serialNumberKey = CocoaMessage(0, 0, "NSString stringWithString:$", @"IOPlatformSerialNumber")
serialNumberAsCFString = IORegistryEntryCreateCFProperty_(platformExpert, serialNumberKey, #Null, 0)
If serialNumberAsCFString
Debug PeekS(CocoaMessage(0, serialNumberAsCFString, "UTF8String"), -1, #PB_UTF8)
CFRelease_(serialNumberAsCFString)
EndIf
IOObjectRelease_(platformExpert)
EndIf
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Mac license info
working fine straight out of the box here, thankyou!!! CocoaMessage to the rescue again, I'm hoping the day will quickly come that my brain "gets" it! i have no idea how you figured out how to do that, and then for example if you found Objective C code how you knew to port it over to PB. One day i will understand! lottts of reading still to do in the meantime, lol
Re: Mac license info
I converted the second solution that was posted on this pageKeya wrote:i have no idea how you figured out how to do that
http://stackoverflow.com/questions/1973 ... ial-number
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Mac license info
Ahh!!! it looks like it might be a great little study piece for people like me wanting to learn porting like this, Rosetta stone style. COFFEE TIME!
Code: Select all
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
// Returns the serial number as a CFString.
// It is the caller's responsibility to release the returned CFString when done with it.
void CopySerialNumber(CFStringRef *serialNumber)
{
if (serialNumber != NULL) {
*serialNumber = NULL;
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
if (platformExpert) {
CFTypeRef serialNumberAsCFString =
IORegistryEntryCreateCFProperty(platformExpert,
CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0);
if (serialNumberAsCFString) {
*serialNumber = serialNumberAsCFString;
}
IOObjectRelease(platformExpert);
}
}
}
Re: Mac license info
Since this is a solution which doesn't uitilize the Cocoa framework, I had already posted an example nearly 4 years ago (it also displays the UUID and Wilbert even modified it to also work on x64 and with Unicode... ):
http://www.purebasic.fr/english/viewtop ... 81&start=5
http://www.purebasic.fr/english/viewtop ... 81&start=5
Re: Mac license info
I didn't rememberShardik wrote:Since this is a solution which doesn't uitilize the Cocoa framework, I had already posted an example nearly 4 years ago (it also displays the UUID and Wilbert even modified it to also work on x64 and with Unicode... ):
http://www.purebasic.fr/english/viewtop ... 81&start=5
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)