Mac 获取系统信息

来源:互联网 发布:淘宝一件代发货源 编辑:程序博客网 时间:2024/06/01 09:15
- (void)iotest{    //如果你需要获得其它硬件的信息,将代码中的AppleAHCIDiskDriver替换为对应的键值就OK了,比如要获取电池信息就用AppleSmartBattery。    io_iterator_t iterator;    kern_return_t kr;    io_object_t   driver;    CFMutableDictionaryRef matchDictionary = IOServiceMatching("AppleAHCIDiskDriver");    kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchDictionary, &iterator);    if (kr != kIOReturnSuccess)    {        return;    }    while ((driver = IOIteratorNext(iterator)) != 0)    {        CFMutableDictionaryRef properties = NULL;        kr = IORegistryEntryCreateCFProperties(driver,                                               &properties,                                               kCFAllocatorDefault,                                               kNilOptions);        if (kr != kIOReturnSuccess || properties == NULL)        {            continue;        }        NSLog(@"%@",(__bridge NSDictionary*)properties);    }}
原创粉丝点击