2012-07-23 41 views
0

通過鍵入:system_profiler SPHardwareDataType | grep'序列號' 我得到2個序列號。如何使用Cocoa獲得序列號(處理器托盤)

第一(「序列號(系統)」)可以放在NSString由:

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

,我沒有找到我怎麼能得到第二:序列號(處理器托盤)

任何想法?

謝謝

回答

-1

答:

(NSString *)IORegistryEntryCreateCFProperty(IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"), CFSTR("processor-memory-board-serial-number"), kCFAllocatorDefault, 0); 
+0

這不適合我。 – 2013-07-14 16:54:50

0

在一個更優雅的方式:)

#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; 
} 

然後:鐺SnTray.m -framework由於IOKit -framework基金會-o SnTray.o

Then ./SnTray.o

我不能做更多:)

相關問題