0

By typing : system_profiler SPHardwareDataType | grep 'Serial Number' I get 2 serial numbers.

The first ("Serial Number (system)") can be put in NSString by :

(NSString *)IORegistryEntryCreateCFProperty(IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"), CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)

and I didn't find how I can get the second : Serial Number (processor tray)

Any ideas?

Thank you

Carelinkz
  • 936
  • 8
  • 27
Stephane
  • 391
  • 1
  • 2
  • 13

2 Answers2

0

In a more elegant way :)

#import <Foundation/Foundation.h>

int main()
{
    CFTypeRef aCFProperty;

    if ((aCFProperty = IORegistryEntryCreateCFProperty(IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"), CFSTR("processor-memory-board-serial-number"), kCFAllocatorDefault, 0)) != NULL )
    {
        NSLog(@"Processor tray Serial Number : %@", aCFProperty);
        CFRelease(aCFProperty);
    }

    return 1;
}

Then : clang SnTray.m -framework IOKit -framework Foundation -o SnTray.o

Then ./SnTray.o

i cant do more :)

Stephane
  • 391
  • 1
  • 2
  • 13
-1

Answer:

(NSString *)IORegistryEntryCreateCFProperty(IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"), CFSTR("processor-memory-board-serial-number"), kCFAllocatorDefault, 0);
zondo
  • 19,901
  • 8
  • 44
  • 83
Stephane
  • 391
  • 1
  • 2
  • 13