[Qt] 获取本机MAC地址


  QString address;

  auto interfaces = QNetworkInterface::allInterfaces();


  for (int i = 0; i < interfaces.length(); i++) {

      if (interfaces[i].isValid()) {

          address = interfaces[i].hardwareAddress();

          break;

      }

  }


  if (address.isEmpty()) {

      qWarning("Local hardware address acquisition failed!");

  }


本文为我原创

本文禁止转载或摘编

-- --
  • 投诉或建议
评论