美文网首页
Mac: 型号、处理器(module, processor )获

Mac: 型号、处理器(module, processor )获

作者: Youzhicha | 来源:发表于2022-02-21 11:47 被阅读0次
// Module
 char buf[100];
 size_t length = 100;
 memset(buf, 0, length);
  int intErr = 0;
  intErr = sysctlbyname("hw.model", buf, &length, NULL, 0);
  if (intErr != 0) {
     cout  << "Error in sysctlbyname(): " << intErr;
  } else {
     cout << "Hardware model: " << buf;
    }


// Processor 
char buf2[100];
size_t buflen2 = 100;
memset(buf2, 0, length2);
sysctlbyname("machdep.cpu.brand_string", &buf2, &buflen2, NULL, 0);
 

相关文章

网友评论

      本文标题:Mac: 型号、处理器(module, processor )获

      本文链接:https://www.haomeiwen.com/subject/ygablrtx.html