[win] updatesvc: fix app lang detection

This commit is contained in:
SimplestStudio
2024-02-12 19:50:37 +02:00
parent a489fe5e04
commit db2b5a98ce

View File

@ -117,8 +117,8 @@ namespace NS_Utils
wstring GetAppLanguage()
{
wstring lang = TEXT("en_US"), subkey = TEXT("SOFTWARE\\" REG_GROUP_KEY "\\" REG_APP_NAME);
HKEY hKey = NULL;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, subkey.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) {
HKEY hKey = NULL, hRootKey = isRunAsApp() ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
if (RegOpenKeyEx(hRootKey, subkey.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) {
DWORD type = REG_SZ, cbData = 0;
if (RegGetValue(hKey, NULL, TEXT("locale"), RRF_RT_REG_SZ, &type, NULL, &cbData) == ERROR_SUCCESS) {
wchar_t *pvData = (wchar_t*)malloc(cbData);