From 829fe6c6bc33d53fda9c31fd45a37e1df87befff Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 30 一月 2026 11:16:24 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang
---
SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
index c1c2459..ae284a7 100644
--- a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
+++ b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
@@ -417,19 +417,34 @@
strAppName = strAppName.Left(strAppName.ReverseFind('.'));
HKEY hKey;
- LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE, &hKey);
+ LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_READ | KEY_WRITE, &hKey);
if (lRet != ERROR_SUCCESS) {
return false;
}
+ DWORD dwType = 0;
+ TCHAR szValue[MAX_PATH] = { 0 };
+ DWORD dwSize = sizeof(szValue);
+ lRet = RegQueryValueEx(hKey, strAppName, 0, &dwType, (LPBYTE)szValue, &dwSize);
+
if (bEnable) {
- // 璁剧疆鑷惎
- lRet = RegSetValueEx(hKey, strAppName, 0, REG_SZ, (BYTE*)(LPCTSTR)strAppPath, (strAppPath.GetLength() + 1) * sizeof(TCHAR));
+ if (lRet != ERROR_SUCCESS || _tcsicmp(szValue, strAppPath) != 0) {
+ // 璁剧疆鑷惎
+ lRet = RegSetValueEx(hKey, strAppName, 0, REG_SZ, (BYTE*)(LPCTSTR)strAppPath, (strAppPath.GetLength() + 1) * sizeof(TCHAR));
+ }
+ else {
+ lRet = ERROR_SUCCESS;
+ }
}
else {
- // 鍙栨秷鑷惎
- lRet = RegDeleteValue(hKey, strAppName);
+ if (lRet == ERROR_SUCCESS) {
+ // 鍙栨秷鑷惎
+ lRet = RegDeleteValue(hKey, strAppName);
+ }
+ else {
+ lRet = ERROR_SUCCESS;
+ }
}
RegCloseKey(hKey);
--
Gitblit v1.9.3