diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-05-20 14:22:09 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2022-05-23 20:56:11 +0800 |
commit | 80996d2e5d6d04b08452cf507f6ced7d8a09068c (patch) | |
tree | 6753fc38d4899f6f734f78798047133e983d88a9 /src/corelib/global/qglobal.cpp | |
parent | 1ae4ffefbbf6dd8d0e29b7253c9ea61b0ebccaa5 (diff) |
qglobal: resolve one Qt6 TODO
Tested with MSVC 2022 locally and this change doesn't
break the bootstrapped builds.
Change-Id: Ieeb9a77035d889b9c1ed0c0c3488ac8802879282
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 1d20b4f27a..cd78dfde1a 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3003,18 +3003,10 @@ QByteArray QSysInfo::machineUniqueId() } #elif defined(Q_OS_WIN) // Let's poke at the registry - // ### Qt 6: Use new helpers from qwinregistry.cpp (once bootstrap builds are obsolete) - HKEY key = NULL; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ | KEY_WOW64_64KEY, &key) - == ERROR_SUCCESS) { - wchar_t buffer[UuidStringLen + 1]; - DWORD size = sizeof(buffer); - bool ok = (RegQueryValueEx(key, L"MachineGuid", NULL, NULL, (LPBYTE)buffer, &size) == - ERROR_SUCCESS); - RegCloseKey(key); - if (ok) - return QStringView(buffer, (size - 1) / 2).toLatin1(); - } + const QString machineGuid = QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Cryptography)") + .stringValue(u"MachineGuid"_s); + if (!machineGuid.isEmpty()) + return machineGuid.toLatin1(); #endif return QByteArray(); } |