From c8a5a82994e513acb00ba0e1f0b882ccbb18a6db Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周二, 26 12月 2023 05:15:47 +0800 Subject: [PATCH] clean code --- src/core/qwindowkit_windows.cpp | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/core/qwindowkit_windows.cpp b/src/core/qwindowkit_windows.cpp index 826c454..8292de5 100644 --- a/src/core/qwindowkit_windows.cpp +++ b/src/core/qwindowkit_windows.cpp @@ -2,22 +2,24 @@ namespace QWK { - typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); - - RTL_OSVERSIONINFOW GetRealOSVersion() { - HMODULE hMod = GetModuleHandleW(L"ntdll.dll"); - if (hMod) { - auto fxPtr = reinterpret_cast<RtlGetVersionPtr>(GetProcAddress(hMod, "RtlGetVersion")); - if (fxPtr != nullptr) { - RTL_OSVERSIONINFOW rovi = {0}; - rovi.dwOSVersionInfoSize = sizeof(rovi); - if (0 == fxPtr(&rovi)) { - return rovi; - } - } - } - RTL_OSVERSIONINFOW rovi = {0}; + static RTL_OSVERSIONINFOW GetRealOSVersionImpl() { + HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll"); + using RtlGetVersionPtr = NTSTATUS(WINAPI *)(PRTL_OSVERSIONINFOW); + auto pRtlGetVersion = + reinterpret_cast<RtlGetVersionPtr>(::GetProcAddress(hMod, "RtlGetVersion")); + RTL_OSVERSIONINFOW rovi{}; + rovi.dwOSVersionInfoSize = sizeof(rovi); + pRtlGetVersion(&rovi); return rovi; } + namespace Private { + + RTL_OSVERSIONINFOW GetRealOSVersion() { + static const auto result = GetRealOSVersionImpl(); + return result; + } + + } + } \ No newline at end of file -- Gitblit v1.9.1