mpc-hc icon indicating copy to clipboard operation
mpc-hc copied to clipboard

ToDo: support reading default settings from HKLM registry key

Open clsid2 opened this issue 1 year ago • 0 comments

This would be useful for sysadmins and installers.

Step 1:

Port profile code from MPC-BE to replace current profile functions implemented in CMPlayerCApp and WinAPI (such as GetProfileInt/WriteProfileInt). It is basically a custom implementation of that same functionality. We can extend it to do next steps.

Step 2:

Allow reading from HKLM until end of CAppSettings::LoadSettings(). Which in current code is signaled by bInitialized=true.

At application start do the following:

  1. Check if HKLM settings key exists. If it does then allow reading settings from HKLM. Whether it should be preferred over HKCU is determined below.
  2. Read value SettingsReset from HKLM and HKCU. Value is 0 if not existing. If value from HKLM is larger than 0 and larger than from HKCU, then delete whole HKCU key to reset user settings to internal defaults (or whatever is specified by HKLM). Set HKLM as preferred. Set HKCU as unavailable (since it is empty) until end of LoadSettings.
  3. Read value SettingsTimestamp from HKLM and HKCU. If HKLM value is larger, then it means that settings are read from HKLM first, and if not found, read from HKCU. Otherwise HKCU is tried first.
  4. At end of LoadSettings write updated SettingsReset and SettingsTimestamp values to HKCU so they are equal to HKLM.

An epoch value is logical for these two new registry key values. But a date in ISO format would work fine too. That is up to end users.

SettingsTimestamp allows pushing updated settings to individual user accounts. SettingsReset allows doing a full settings reset.

Step 3:

When storing settings to INI file, redirect contents of MediaHistory section to a separate INI file.

clsid2 avatar Nov 17 '23 00:11 clsid2