mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Call Windows API directly
We already bumped the OS requirement to Windows 7 and those functions can be called directly without the need to load them first.
This commit is contained in:
parent
975b44d05f
commit
7276a79cef
5 changed files with 15 additions and 39 deletions
|
@ -4531,23 +4531,15 @@ namespace
|
|||
QString convertIfaceNameToGuid(const QString &name)
|
||||
{
|
||||
// Under Windows XP or on Qt version <= 5.5 'name' will be a GUID already.
|
||||
QUuid uuid(name);
|
||||
const QUuid uuid(name);
|
||||
if (!uuid.isNull())
|
||||
return uuid.toString().toUpper(); // Libtorrent expects the GUID in uppercase
|
||||
|
||||
using PCONVERTIFACENAMETOLUID = NETIO_STATUS (WINAPI *)(const WCHAR *, PNET_LUID);
|
||||
const auto ConvertIfaceNameToLuid = Utils::Misc::loadWinAPI<PCONVERTIFACENAMETOLUID>("Iphlpapi.dll", "ConvertInterfaceNameToLuidW");
|
||||
if (!ConvertIfaceNameToLuid) return {};
|
||||
|
||||
using PCONVERTIFACELUIDTOGUID = NETIO_STATUS (WINAPI *)(const NET_LUID *, GUID *);
|
||||
const auto ConvertIfaceLuidToGuid = Utils::Misc::loadWinAPI<PCONVERTIFACELUIDTOGUID>("Iphlpapi.dll", "ConvertInterfaceLuidToGuid");
|
||||
if (!ConvertIfaceLuidToGuid) return {};
|
||||
|
||||
NET_LUID luid;
|
||||
const LONG res = ConvertIfaceNameToLuid(name.toStdWString().c_str(), &luid);
|
||||
NET_LUID luid {};
|
||||
const LONG res = ::ConvertInterfaceNameToLuidW(name.toStdWString().c_str(), &luid);
|
||||
if (res == 0) {
|
||||
GUID guid;
|
||||
if (ConvertIfaceLuidToGuid(&luid, &guid) == 0)
|
||||
if (::ConvertInterfaceLuidToGuid(&luid, &guid) == 0)
|
||||
return QUuid(guid).toString().toUpper();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue