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

2022-02-21  本文已影响0人  Youzhicha
// 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);
 
上一篇 下一篇

猜你喜欢

热点阅读