diff --git a/CompatibilityManager/Resources/Strings.Designer.cs b/CompatibilityManager/Resources/Strings.Designer.cs index 0b807b8..9b020e6 100644 --- a/CompatibilityManager/Resources/Strings.Designer.cs +++ b/CompatibilityManager/Resources/Strings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace CompatibilityManager.Resources { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Strings { @@ -33,7 +33,7 @@ internal Strings() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Strings() { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Strings() { } /// - /// Looks up a localized string similar to Add files. + /// Add files과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AddFiles { get { @@ -70,7 +70,7 @@ public static string AddFiles { } /// - /// Looks up a localized string similar to Pick one or more executables to add to the list. + /// Pick one or more executables to add to the list과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AddFilesDescription { get { @@ -79,7 +79,7 @@ public static string AddFilesDescription { } /// - /// Looks up a localized string similar to Add folder. + /// Add folder과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AddFolder { get { @@ -88,9 +88,9 @@ public static string AddFolder { } /// - /// Looks up a localized string similar to Pick a folder to add to the list. + /// Pick a folder to add to the list. ///The application will recursively set flags on all executables found in this folder. - ///If you pick something stupid like "C:"... well, you have been warned! :). + ///If you pick something stupid like "C:"... well, you have been warned! :)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AddFolderDescription { get { @@ -99,7 +99,7 @@ public static string AddFolderDescription { } /// - /// Looks up a localized string similar to Additional flags. + /// Additional flags과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AdditionalFlags { get { @@ -108,7 +108,7 @@ public static string AdditionalFlags { } /// - /// Looks up a localized string similar to Multi-selection settings. + /// Multi-selection settings과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string AggregatedSettings { get { @@ -117,7 +117,7 @@ public static string AggregatedSettings { } /// - /// Looks up a localized string similar to Compatibility Manager. + /// Compatibility Manager과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ApplicationName { get { @@ -126,7 +126,7 @@ public static string ApplicationName { } /// - /// Looks up a localized string similar to Application settings. + /// Application settings과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ApplicationSettings { get { @@ -135,7 +135,7 @@ public static string ApplicationSettings { } /// - /// Looks up a localized string similar to This should never happen: if it happened, either all hell broke loose, a Windows update broke my stuff (fuck you too, Bill!), or (most likely) I'm just a very bad programmer. Please report ASAP!. + /// This should never happen: if it happened, either all hell broke loose, a Windows update broke my stuff (fuck you too, Bill!), or (most likely) I'm just a very bad programmer. Please report ASAP!과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CatastrophicFailureException { get { @@ -144,7 +144,7 @@ public static string CatastrophicFailureException { } /// - /// Looks up a localized string similar to Clear (remove from registry on save). + /// Clear (remove from registry on save)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Clear { get { @@ -153,7 +153,7 @@ public static string Clear { } /// - /// Looks up a localized string similar to Reduced color mode. + /// Reduced color mode과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ColorMode { get { @@ -162,7 +162,7 @@ public static string ColorMode { } /// - /// Looks up a localized string similar to 16-bit (65536) color. + /// 16-bit (65536) color과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ColorMode_COLOR16BIT { get { @@ -171,7 +171,7 @@ public static string ColorMode_COLOR16BIT { } /// - /// Looks up a localized string similar to 8-bit (256) color. + /// 8-bit (256) color과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ColorMode_COLOR256 { get { @@ -180,7 +180,7 @@ public static string ColorMode_COLOR256 { } /// - /// Looks up a localized string similar to Run this program in compatibility mode for:. + /// Run this program in compatibility mode for:과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode { get { @@ -189,7 +189,7 @@ public static string CompatibilityMode { } /// - /// Looks up a localized string similar to Windows Vista. + /// Windows Vista과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_VISTARTM { get { @@ -198,7 +198,7 @@ public static string CompatibilityMode_VISTARTM { } /// - /// Looks up a localized string similar to Windows Vista (Service Pack 1). + /// Windows Vista (Service Pack 1)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_VISTASP1 { get { @@ -207,7 +207,7 @@ public static string CompatibilityMode_VISTASP1 { } /// - /// Looks up a localized string similar to Windows Vista (Service Pack 2). + /// Windows Vista (Service Pack 2)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_VISTASP2 { get { @@ -216,7 +216,7 @@ public static string CompatibilityMode_VISTASP2 { } /// - /// Looks up a localized string similar to Windows 7. + /// Windows 7과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WIN7RTM { get { @@ -225,7 +225,7 @@ public static string CompatibilityMode_WIN7RTM { } /// - /// Looks up a localized string similar to Windows 8. + /// Windows 8과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WIN8RTM { get { @@ -234,7 +234,7 @@ public static string CompatibilityMode_WIN8RTM { } /// - /// Looks up a localized string similar to Windows 95. + /// Windows 95과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WIN95 { get { @@ -243,7 +243,7 @@ public static string CompatibilityMode_WIN95 { } /// - /// Looks up a localized string similar to Windows 98. + /// Windows 98과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WIN98 { get { @@ -252,7 +252,7 @@ public static string CompatibilityMode_WIN98 { } /// - /// Looks up a localized string similar to Windows XP (Service Pack 2). + /// Windows XP (Service Pack 2)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WINXPSP2 { get { @@ -261,7 +261,7 @@ public static string CompatibilityMode_WINXPSP2 { } /// - /// Looks up a localized string similar to Windows XP (Service Pack 3). + /// Windows XP (Service Pack 3)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string CompatibilityMode_WINXPSP3 { get { @@ -270,7 +270,7 @@ public static string CompatibilityMode_WINXPSP3 { } /// - /// Looks up a localized string similar to Disable fullscreen optimizations. + /// Disable fullscreen optimizations과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string DisableFullscreenOptimizations { get { @@ -279,8 +279,8 @@ public static string DisableFullscreenOptimizations { } /// - /// Looks up a localized string similar to Override high DPI scaling behavior. - ///Scaling performed by:. + /// Override high DPI scaling behavior. + ///Scaling performed by:과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string DPIScaling { get { @@ -289,7 +289,7 @@ public static string DPIScaling { } /// - /// Looks up a localized string similar to System. + /// System과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string DPIScaling_DPIUNAWARE { get { @@ -298,7 +298,7 @@ public static string DPIScaling_DPIUNAWARE { } /// - /// Looks up a localized string similar to System (Enhanced). + /// System (Enhanced)과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string DPIScaling_GDIDPISCALING { get { @@ -307,7 +307,7 @@ public static string DPIScaling_GDIDPISCALING { } /// - /// Looks up a localized string similar to Application. + /// Application과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string DPIScaling_HIGHDPIAWARE { get { @@ -316,7 +316,7 @@ public static string DPIScaling_HIGHDPIAWARE { } /// - /// Looks up a localized string similar to Show HKLM ("Change settings for all users"). + /// Show HKLM ("Change settings for all users")과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Elevate { get { @@ -325,7 +325,7 @@ public static string Elevate { } /// - /// Looks up a localized string similar to {0} must be an Enum type.. + /// {0} must be an Enum type.과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string EnumTypeArgumentException { get { @@ -334,7 +334,7 @@ public static string EnumTypeArgumentException { } /// - /// Looks up a localized string similar to Export. + /// Export과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Export { get { @@ -343,7 +343,7 @@ public static string Export { } /// - /// Looks up a localized string similar to . + /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ExportDescription { get { @@ -352,7 +352,16 @@ public static string ExportDescription { } /// - /// Looks up a localized string similar to Current User. + /// [Global Configuration]과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string GlobalConfig { + get { + return ResourceManager.GetString("GlobalConfig", resourceCulture); + } + } + + /// + /// Current User과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string HKCU { get { @@ -361,7 +370,7 @@ public static string HKCU { } /// - /// Looks up a localized string similar to Local Machine. + /// Local Machine과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string HKLM { get { @@ -370,7 +379,7 @@ public static string HKLM { } /// - /// Looks up a localized string similar to Import. + /// Import과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Import { get { @@ -379,7 +388,7 @@ public static string Import { } /// - /// Looks up a localized string similar to Pick a .reg file to import. + /// Pick a .reg file to import과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string ImportDescription { get { @@ -388,8 +397,8 @@ public static string ImportDescription { } /// - /// Looks up a localized string similar to Please wait... - ///We're in the middle of some calibrations.. + /// Please wait... + ///We're in the middle of some calibrations.과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string PleaseWait { get { @@ -398,7 +407,7 @@ public static string PleaseWait { } /// - /// Looks up a localized string similar to Regedit. + /// Regedit과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Regedit { get { @@ -407,7 +416,7 @@ public static string Regedit { } /// - /// Looks up a localized string similar to Reload selected from registry. + /// Reload selected from registry과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Reload { get { @@ -416,7 +425,7 @@ public static string Reload { } /// - /// Looks up a localized string similar to Run in 640 x 480 resolution. + /// Run in 640 x 480 resolution과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Resolution640x480 { get { @@ -425,7 +434,7 @@ public static string Resolution640x480 { } /// - /// Looks up a localized string similar to Run this program as an administrator. + /// Run this program as an administrator과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string RunAsAdministrator { get { @@ -434,7 +443,7 @@ public static string RunAsAdministrator { } /// - /// Looks up a localized string similar to Save selected to registry. + /// Save selected to registry과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string Save { get { @@ -443,10 +452,12 @@ public static string Save { } /// - /// Looks up a localized string similar to This will save settings for each application to the registry. + /// This will save settings for each application to the registry. ///If no settings have been selected for an application, it will be removed from the registry entries. /// - ///Confirm?. + ///For Steam games, the global configuration changes will apply after restarting Steam. + /// + ///Confirm?과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string SaveWarning { get { @@ -455,7 +466,7 @@ public static string SaveWarning { } /// - /// Looks up a localized string similar to Select all. + /// Select all과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string SelectAll { get { @@ -464,7 +475,7 @@ public static string SelectAll { } /// - /// Looks up a localized string similar to Couldn't detect OS version. {0}. + /// Couldn't detect OS version. {0}과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string UnknownOSException { get { @@ -473,7 +484,7 @@ public static string UnknownOSException { } /// - /// Looks up a localized string similar to Unselect all. + /// Unselect all과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string UnselectAll { get { @@ -482,7 +493,7 @@ public static string UnselectAll { } /// - /// Looks up a localized string similar to Here be dragons!. + /// Here be dragons!과(와) 유사한 지역화된 문자열을 찾습니다. /// public static string WarningTitle { get { diff --git a/CompatibilityManager/Resources/Strings.resx b/CompatibilityManager/Resources/Strings.resx index ae45954..ba52b23 100644 --- a/CompatibilityManager/Resources/Strings.resx +++ b/CompatibilityManager/Resources/Strings.resx @@ -205,6 +205,8 @@ If you pick something stupid like "C:"... well, you have been warned! :) This will save settings for each application to the registry. If no settings have been selected for an application, it will be removed from the registry entries. +For Steam games, the global configuration changes will apply after restarting Steam. + Confirm? @@ -265,4 +267,7 @@ We're in the middle of some calibrations. Pick a .reg file to import + + [Global Configuration] + \ No newline at end of file diff --git a/CompatibilityManager/Services/RegistryServices.cs b/CompatibilityManager/Services/RegistryServices.cs index 22c63f6..13d2021 100644 --- a/CompatibilityManager/Services/RegistryServices.cs +++ b/CompatibilityManager/Services/RegistryServices.cs @@ -17,20 +17,36 @@ public static class RegistryServices private const string LastKeyRegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit"; private const string LastKeyValueName = @"LastKey"; + + private const string HKCUEnvVarRegistryKey = @"Environment"; + private const string HKLMEnvVarRegistryKey = @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; + + public const string GlobalCompatEnvVarRegistryName = "__COMPAT_LAYER"; + private static string HKCU = $@"HKCU\{AppCompatFlagsRegistryKey}"; private static string HKLM = $@"HKLM\{AppCompatFlagsRegistryKey}"; - public static RegistryKey HKCUKey { get; } = GetRegistryKey(hklm: false); - public static RegistryKey HKLMKey { get; } = GetRegistryKey(hklm: true); + public static RegistryKey HKCUKey { get; } = GetRegistryKey(hklm: false, global: false); + public static RegistryKey HKLMKey { get; } = GetRegistryKey(hklm: true, global: false); + public static RegistryKey HKCUEnvVarKey { get; } = GetRegistryKey(hklm: false, global: true); + public static RegistryKey HKLMEnvVarKey { get; } = GetRegistryKey(hklm: true, global: true); #endregion - private static RegistryKey GetRegistryKey(bool hklm = false) + private static RegistryKey GetRegistryKey(bool hklm = false, bool global = false) { try { - if (hklm) { return Registry.LocalMachine.CreateSubKey(AppCompatFlagsRegistryKey); } - else { return Registry.CurrentUser.CreateSubKey(AppCompatFlagsRegistryKey); } + if (global) + { + if (hklm) { return Registry.LocalMachine.CreateSubKey(HKLMEnvVarRegistryKey); } + else { return Registry.CurrentUser.CreateSubKey(HKCUEnvVarRegistryKey); } + } + else + { + if (hklm) { return Registry.LocalMachine.CreateSubKey(AppCompatFlagsRegistryKey); } + else { return Registry.CurrentUser.CreateSubKey(AppCompatFlagsRegistryKey); } + } } catch (UnauthorizedAccessException) { @@ -44,6 +60,17 @@ private static RegistryKey GetRegistryKey(bool hklm = false) public static IEnumerable GetApplications(RegistryKey registryKey) { var applications = new List(); + var regName = registryKey.ToString(); + + if (regName.StartsWith("HKEY_CURRENT_USER") || regName.StartsWith("HKCU")) + { + applications.Add(new ApplicationViewModel(Resources.Strings.GlobalConfig, HKCUEnvVarKey)); + } + else if (regName.StartsWith("HKEY_LOCAL_MACHINE") || regName.StartsWith("HKLM")) + { + applications.Add(new ApplicationViewModel(Resources.Strings.GlobalConfig, HKLMEnvVarKey)); + } + foreach (var path in registryKey.GetValueNames()) { applications.Add(new ApplicationViewModel(path, registryKey)); @@ -56,7 +83,8 @@ public static IEnumerable GetApplications(RegistryKey regi /// public static string GetApplicationRegistryString(RegistryKey key, string path) { - return (string)key.GetValue(path); + var str = path == Resources.Strings.GlobalConfig ? RegistryServices.GlobalCompatEnvVarRegistryName : path; + return (string)key.GetValue(str); } /// diff --git a/CompatibilityManager/ViewModels/MainViewModel.cs b/CompatibilityManager/ViewModels/MainViewModel.cs index 6c77b03..bdf3eda 100644 --- a/CompatibilityManager/ViewModels/MainViewModel.cs +++ b/CompatibilityManager/ViewModels/MainViewModel.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; @@ -60,6 +61,9 @@ public SettingsViewModel DisplayedSettings public bool IsAnySelected => this.SelectedApplications.Any(); + private const int HWND_BROADCAST = 0xffff; + private const uint WM_SETTINGCHANGE = 0x001a; + #endregion #region Commands @@ -163,17 +167,30 @@ private async void Save(IEnumerable applications) foreach (var application in applications) { var appCompatFlags = application.Settings.ToRegistryString(); + var path = application.Path == Resources.Strings.GlobalConfig ? RegistryServices.GlobalCompatEnvVarRegistryName : application.Path; + if (string.IsNullOrWhiteSpace(appCompatFlags)) { - try { application.RegistryKey.DeleteValue(application.Path); } + try { application.RegistryKey.DeleteValue(path); } catch (ArgumentException) { } // Trying to delete application that does not exist in registry -- was added by user but no settings specified - finally { taskApplicationsRemoved.Add(application); } + finally + { + if (application.Path != Resources.Strings.GlobalConfig) + { + taskApplicationsRemoved.Add(application); + } + } } else { - application.RegistryKey.SetValue(application.Path, appCompatFlags); + application.RegistryKey.SetValue(path, appCompatFlags); taskApplicationsModified.Add(application); } + + if (application.Path == Resources.Strings.GlobalConfig) + { + SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_SETTINGCHANGE, (UIntPtr)0, "Environment"); // Send message for applications to update the environment variable -- this makes changes take effect without restarting Explorer. + } } foreach (var application in taskApplicationsModified) @@ -228,5 +245,12 @@ private bool CanElevate() } #endregion + + #region DLL Imports + + [DllImport("user32.dll")] + static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam); + + #endregion } }