- (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);
}
}
Mac 获取系统信息
最新推荐文章于 2022-03-03 21:17:37 发布