diff --git a/trunk/CHANGELOG.txt b/trunk/CHANGELOG.txt index af6d4cd37..170aa0bd3 100644 --- a/trunk/CHANGELOG.txt +++ b/trunk/CHANGELOG.txt @@ -1,5 +1,9 @@ Process Hacker +1.7 + * NEW/IMPROVED: + * New settings system - settings can now be saved anywhere + 1.6 * NEW/IMPROVED: * #2817429 - "Add Port and IP Address columns to Network tab" diff --git a/trunk/ProcessHacker/Help.htm b/trunk/ProcessHacker/Help.htm index 7a79d8682..9b1e93e1a 100644 --- a/trunk/ProcessHacker/Help.htm +++ b/trunk/ProcessHacker/Help.htm @@ -31,10 +31,8 @@ pre {
  • .NET Framework 2.0
  • -

    Configuration Files

    -

    On Windows Vista, the configuration files for Process Hacker are stored in - AppData\Local\wj32. On Windows XP, they are stored in - Local Settings\Application Data\wj32.

    +

    Configuration File

    +

    The settings file for Process Hacker is stored in: [Roaming Application Data]\Process Hacker.

    Command Line Options

    @@ -55,6 +53,8 @@ pre {
    Starts Process Hacker hidden, regardless of any settings.
    -nokph
    Disables KProcessHacker.
    +
    -nosettings
    +
    Uses defaults for all settings and does not attempt to load or save any settings.
    -o [-hwnd hWnd] [-rect x,y,width,height]
    Opens Process Hacker options without the main window. Note that the width and height parts of the rectangle parameter are ignored.
    @@ -62,6 +62,8 @@ pre {
    Opens process properties for the specified process without the main window.
    -pt pid
    Opens token properties for the token of the specified process without the main window.
    +
    -settings filename
    +
    Uses the specified file name as the settings file.
    -t tab
    Opens the specified tab at startup. Use 0 for Processes, 1 for Services and 2 for Network.
    -uninstallkph
    diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 765545763..4de70a10f 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -288,9 +288,11 @@ namespace ProcessHacker "-ip pid\tDisplays the main window, then properties for the specified process.\n" + "-m\tStarts Process Hacker hidden.\n" + "-nokph\tDisables KProcessHacker. Use this if you encounter BSODs.\n" + + "-nosettings\tUses defaults for all settings and does not attempt to load or save any settings.\n" + "-o\tShows Options.\n" + "-pw pid\tDisplays properties for the specified process.\n" + "-pt pid\tDisplays properties for the specified process' token.\n" + + "-settings filename\tUses the specified file name as the settings file.\n" + "-t n\tShows the specified tab. 0 is Processes, 1 is Services and 2 is Network.\n" + "-uninstallkph\tUninstalls the KProcessHacker service.\n" + "-v\tStarts Process Hacker visible.\n" + @@ -321,7 +323,39 @@ namespace ProcessHacker } if (settingsFileName == null) - settingsFileName = Application.StartupPath + "\\settings.xml"; + { + bool success = true; + string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + + try + { + if (!System.IO.Directory.Exists(appData + @"\Process Hacker")) + { + System.IO.Directory.CreateDirectory(appData + @"\Process Hacker"); + } + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to create the settings directory", ex); + success = false; + } + + if (success) + { + settingsFileName = appData + @"\Process Hacker\settings.xml"; + } + else + { + settingsFileName = null; + } + } + + // Make sure we have an absolute path so we don't run into problems + // when saving. + if (settingsFileName != null) + { + settingsFileName = System.IO.Path.GetFullPath(settingsFileName); + } try { @@ -329,8 +363,7 @@ namespace ProcessHacker } catch { - // Settings file is probably corrupt. Delete the settings file - // with confirmation from the user. + // Settings file is probably corrupt. Ask the user. try { ThemingScope.Activate(); } catch { }