diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/kernel/kernel.pri | 2 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinterface_win.cpp | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 671b57ed11..435bfd6c27 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -38,6 +38,8 @@ win32: { kernel/qhostinfo_win.cpp \ kernel/qnetworkinterface_win.cpp LIBS_PRIVATE += -ldnsapi -liphlpapi + DEFINES += WINVER=0x0600 _WIN32_WINNT=0x0600 + } else { SOURCES += kernel/qdnslookup_winrt.cpp \ kernel/qhostinfo_winrt.cpp \ diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index d73d3ecdc9..907638f73e 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -56,6 +57,9 @@ QT_BEGIN_NAMESPACE +typedef NETIO_STATUS (WINAPI *PtrConvertInterfaceLuidToName)(const NET_LUID *, PWSTR, SIZE_T); +static PtrConvertInterfaceLuidToName ptrConvertInterfaceLuidToName = 0; + static void resolveLibs() { // try to find the functions we need from Iphlpapi.dll @@ -66,7 +70,11 @@ static void resolveLibs() Q_ASSERT(iphlpapiHnd); #if defined(Q_OS_WINCE) + // since Windows Embedded Compact 7 + ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceLuidToNameW"); #else + // since Windows Vista + ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, "ConvertInterfaceLuidToNameW"); #endif done = true; } @@ -176,7 +184,16 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP() if (ptr->IfType == IF_TYPE_PPP) iface->flags |= QNetworkInterface::IsPointToPoint; - iface->name = QString::fromLocal8Bit(ptr->AdapterName); + if (ptrConvertInterfaceLuidToName && ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid)) { + // use ConvertInterfaceLuidToName because that returns a friendlier name, though not + // as friendly as FriendlyName below + WCHAR buf[IF_MAX_STRING_SIZE + 1]; + if (ptrConvertInterfaceLuidToName(&ptr->Luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR) + iface->name = QString::fromWCharArray(buf); + } + if (iface->name.isEmpty()) + iface->name = QString::fromLocal8Bit(ptr->AdapterName); + iface->friendlyName = QString::fromWCharArray(ptr->FriendlyName); if (ptr->PhysicalAddressLength) iface->hardwareAddress = iface->makeHwAddress(ptr->PhysicalAddressLength, |