简体   繁体   中英

Set UI Language Windows with SetLocaleInfo

I want to change the default language for windows system. From powershell, there is a way to do this using

Set-WinUILanguageOverride -Language de-DE (Changes language to German)

However, I am looking for a win32 api call for same. Tried SetLocaleInfo , but it wasn't working.The following code prints 0 as the SetLocaleInfo is failing. GetLastError() returned ERROR_INVALID_FLAGS , but not sure which flag needs to go here. Thanks.

int main()
{
    LCID lcid = GetSystemDefaultLCID();
    cout << "system default >> " << lcid << endl;

    wstring regionCode;
    
    //Tatar Russia
    lcid = 1092;
    regionCode = L"0x0444";
    cout << "Tatar Russia " << SetLocaleInfo(lcid, LOCALE_FONTSIGNATURE | LOCALE_SISO639LANGNAME, regionCode.c_str()) << endl;

    return 0;
}

As @Petesh said, The two LCType you used are invalid for the SetLocaleInfo function,and there is no valid flag for SetLocaleInfo that can set the UI language of windows system.

According to the User Interface Language Management :

User UI Language

To retrieve the user UI language, an application can call GetUserDefaultUILanguage or GetUserPreferredUILanguages . The application cannot change the user UI language, as there is no function to set it.

Therefore, there is no suitable Windows32 API that can modify the UI language of the windows system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM