1. SG精度检添加读取注册表功能
2. SG精度检查开机自启动增强,取消时不存在不删除注册表,启动时不存在或路径不一样才修改
| | |
| | | <RESOURCE_FILE>SGMeasurement.rc</RESOURCE_FILE> |
| | | </PropertyGroup> |
| | | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
| | | <DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor> |
| | | <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> |
| | | </PropertyGroup> |
| | | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
| | | <RemoteDebuggerCommand>\\DESKTOP-IODBVIQ\SGMeasurement\$(ProjectName).exe</RemoteDebuggerCommand> |
| | |
| | | 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) { |
| | | 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 { |
| | | if (lRet == ERROR_SUCCESS) { |
| | | // 取消自启 |
| | | lRet = RegDeleteValue(hKey, strAppName); |
| | | } |
| | | else { |
| | | lRet = ERROR_SUCCESS; |
| | | } |
| | | } |
| | | |
| | | RegCloseKey(hKey); |
| | | return (lRet == ERROR_SUCCESS); |