获取有效的MAC地址
获取有效的MAC地址
QString getValidMacAddr()
{
foreach(QNetworkInterface networkInferface, QNetworkInterface::allInterfaces())
{
//get current valid network card
if ( networkInferface.flags().testFlag(QNetworkInterface::IsUp)
&& networkInferface.flags().testFlag(QNetworkInterface::IsRunning)
&& !networkInferface.flags().testFlag(QNetworkInterface::IsLoopBack))
{
//There may be a virtual network card, but we only take the first valid card
return networkInferface.hardwareAddress();
}
}
}