- 
                Notifications
    
You must be signed in to change notification settings  - Fork 271
 
Open
Labels
Description
The extension of #1069 (comment)
Can we refer to the approach of Total Commander in this regard, using redirection to split the ini?
This allows for the separation of roaming configuration and local configuration.
It can also be used to control which configurations remain consistent and which ones differ in a multi-user environment.
For example, the following excerpt
[Layout]
BreadCrumbBar=1
CmdLine=1
CurDir=1
DirectoryTabs=1
DriveBar1=1
DriveBar2=1
DriveBarFlat=1
DriveCombo=0
HistoryHotlistButtons=1
InterfaceFlat=1
KeyButtons=1
StatusBar=1
TabHeader=1
XPthemeBg=1
[Associations]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[Command line history]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SplitPerFile]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SyncOptions]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[USER]
RedirectSection=%COMMANDER_PATH%\User\User.iniIf there is a RedirectSection value encountered during the section, redirect to another ini file.
Some pseudocode
function ReadIni(filePath, section, key) {
	let redirectPath = Win32ApiGetIni(filePath, section, "RedirectSection");
	if (redirectPath) {
		// recursion
		return ReadIni(ResolvePath(redirectPath), section, key);
	} else {
		return Win32ApiGetIni(filePath, section, key);
	}
}
function Win32ApiGetIni(filePath, section, key) {
	let retVal = "";
	GetPrivateProfileString(filePath, section, "", retVal, 0xFF, key);
	return retVal;
}
function ResolvePath(filePath) {
	let resolveedPath = filePath;
	resolveedPath = resolveedPath.replace("%COMMANDER_PATH%", thisApp.exePath);
	resolveedPath = Win32ApiGetFullPathName(resolveedPath);
	return filePath;
}The initial INI file can be redirected according to the following priority:
- If
.\Notepad4.iniexists, the application runs directly in portable mode. - Per-user configuration (customizable by the individual user):
 
[HKEY_CURRENT_USER\SOFTWARE\zufuliu\Notepad4]
IniFileName=%AppData%\zufuliu\Notepad4\Notepad4.ini- System-wide default configuration (set by the administrator):
 
[HKEY_LOCAL_MACHINE\SOFTWARE\zufuliu\Notepad4]
IniFileName= %ProgramData%\zufuliu\Notepad4\Notepad4.ini