SUMMARY:
My goal is to avoid asking for user's preferred language twice: in the installer and in the application, when the user installs the software to the common user's profile.
I know how to use the language choice from installer when the user installs the application for the current user. My question is how should I proceed when the user installs the application for all users and the language choice is stored in HKLM
registry root.
I created software with support for multiple UI languages. When the user changes the language in the application, I save it in the registry (HKCU
root) on application exit. When the application starts, it reads the language back from the registry. It seems, this part is trivial.
In my Inno Setup script, I let users to choose the installer language, and then save this choice to the same registry branch which is used by the installed application (to avoid forcing the user to choose the language twice: in the installer and then in the app). Still nothing complicated yet.
When I added the users an ability to install the application to the common profile (i.e. All Users) everything became much more complicated.
The problem is that HKA
maps to HKLM
root when the user chooses 'All Users', but the application deals with HKCU
root, so it finds nothing there.
Here are main points from my Inno Setup script:
[Setup]
PrivilegesRequiredOverridesAllowed=dialog ;to let users to choose the target user profile, is it correct?
...
[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: de; MessagesFile: "compiler:Languages\German.isl"
Name: fr; MessagesFile: "compiler:Languages\French.isl"
Name: it; MessagesFile: "compiler:Languages\Italian.isl"
...
[Registry]
Root: HKA; Subkey: "Software\{#MyAppName}\Settings"; ValueType: string; ValueName: "Language"; ValueData: "en"; Languages: en
Root: HKA; Subkey: "Software\{#MyAppName}\Settings"; ValueType: string; ValueName: "Language"; ValueData: "de"; Languages: de
Root: HKA; Subkey: "Software\{#MyAppName}\Settings"; ValueType: string; ValueName: "Language"; ValueData: "fr"; Languages: fr
Root: HKA; Subkey: "Software\{#MyAppName}\Settings"; ValueType: string; ValueName: "Language"; ValueData: "it"; Languages: it
...
So, my questions are:
In such conditions, should my software always read the language from HKLM
root first, and if not found, switch to HKCU
? If yes, then the application must be launched under Admin privileges, correct?
Alternatively, I could duplicate the registry part and store the language in HKCU
root too regardless of the profile choice. But mixing profiles in the setup script is, it seems, a bad practice? And this helps to the current user only...
May be, I'm making it too complicated, and easier ways exist? What is the common practice to achieve my goal (if such practice exists)?
Probably, the question is wider than just Inno Setup and registry related, but I could not find how to correctly categorize it. Any help with categorizing is appreciated.
May be, I'm making it too complicated, and easier ways exist? What is the common practice to achieve my goal (if such practice exists)?
Yes, I believe you are overcomplicating this issue. All you need to do is change the logic of your own application when it starts.
HKLM
and default to that.This is not an Inno Setup matter.
In such conditions, should my software always read the language from
HKLM
root first, and if not found, switch toHKCU
? If yes, then the application must be launched under Admin privileges, correct?
You do not need Admin rights to read from HKLM
. You need aAmin rights to write to HKLM
.
You don't say what your coding environment is or anything for your application, but I use CSettingsStore
to simplify reading registry data from HKLM
etc..