From f0886bf28c6c3911b416dcecad9c1b1a2f16d26e Mon Sep 17 00:00:00 2001
From: "denis.sumin" <denis.smolov@demlabs.net>
Date: Fri, 14 Mar 2025 16:06:40 +0700
Subject: [PATCH] [[*] fix win build

---
 CellframeNodeDiagtool/DiagDataManager.cpp | 48 +++++++++++++++++++++++
 CellframeNodeDiagtool/NotifyWorker.cpp    | 15 +++++++
 2 files changed, 63 insertions(+)

diff --git a/CellframeNodeDiagtool/DiagDataManager.cpp b/CellframeNodeDiagtool/DiagDataManager.cpp
index 6f0217b..1374bbf 100644
--- a/CellframeNodeDiagtool/DiagDataManager.cpp
+++ b/CellframeNodeDiagtool/DiagDataManager.cpp
@@ -7,6 +7,54 @@
 
 DiagDataManager* DiagDataManager::m_instance = nullptr;
 
+#ifdef WIN32
+LONG DapConfigToolController::GetDWORDRegKey(HKEY hKey, const std::wstring &strValueName, DWORD &nValue, DWORD nDefaultValue)
+{
+    nValue = nDefaultValue;
+    DWORD dwBufferSize(sizeof(DWORD));
+    DWORD nResult(0);
+    LONG nError = ::RegQueryValueExW(hKey,
+                                     strValueName.c_str(),
+                                     0,
+                                     NULL,
+                                     reinterpret_cast<LPBYTE>(&nResult),
+                                     &dwBufferSize);
+    if (ERROR_SUCCESS == nError)
+    {
+        nValue = nResult;
+    }
+    return nError;
+}
+
+
+LONG DapConfigToolController::GetBoolRegKey(HKEY hKey, const std::wstring &strValueName, bool &bValue, bool bDefaultValue)
+{
+    DWORD nDefValue((bDefaultValue) ? 1 : 0);
+    DWORD nResult(nDefValue);
+    LONG nError = GetDWORDRegKey(hKey, strValueName.c_str(), nResult, nDefValue);
+    if (ERROR_SUCCESS == nError)
+    {
+        bValue = (nResult != 0) ? true : false;
+    }
+    return nError;
+}
+
+
+LONG DapConfigToolController::GetStringRegKey(HKEY hKey, const std::wstring &strValueName, std::wstring &strValue, const std::wstring &strDefaultValue)
+{
+    strValue = strDefaultValue;
+    WCHAR szBuffer[512];
+    DWORD dwBufferSize = sizeof(szBuffer);
+    ULONG nError;
+    nError = RegQueryValueExW(hKey, strValueName.c_str(), 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);
+    if (ERROR_SUCCESS == nError)
+    {
+        strValue = szBuffer;
+    }
+    return nError;
+}
+#endif
+
 
 DiagDataManager::DiagDataManager()
 {
diff --git a/CellframeNodeDiagtool/NotifyWorker.cpp b/CellframeNodeDiagtool/NotifyWorker.cpp
index ae87886..5e360b4 100644
--- a/CellframeNodeDiagtool/NotifyWorker.cpp
+++ b/CellframeNodeDiagtool/NotifyWorker.cpp
@@ -6,6 +6,21 @@
 #include "registry.h"
 #endif
 
+#ifdef WIN32
+LONG GetStringRegKey(HKEY hKey, const std::wstring &strValueName, std::wstring &strValue, const std::wstring &strDefaultValue)
+{
+    strValue = strDefaultValue;
+    WCHAR szBuffer[512];
+    DWORD dwBufferSize = sizeof(szBuffer);
+    ULONG nError;
+    nError = RegQueryValueExW(hKey, strValueName.c_str(), 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);
+    if (ERROR_SUCCESS == nError)
+    {
+        strValue = szBuffer;
+    }
+    return nError;
+}
+#endif
 
 bool NotifyWorker::initConfTool()
 {
-- 
GitLab