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

// 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 )获取)