示例#1
0
 /// <summary>
 /// Writes a value 1 in the registrykey and as aresult the dont show again dialog will not be launched.
 /// </summary>
 /// <param name="registryKey">The key to write to.</param>
 /// <param name="value">The value to write.</param>
 internal static void WriteDontShowAgainValue(string registryKey, int value)
 {
     using (RegistryKey root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings))
     {
         if (root != null)
         {
             using (RegistryKey key = root.OpenSubKey(GeneralSubKey, true))
             {
                 key.SetValue(registryKey, value, RegistryValueKind.DWord);
             }
         }
     }
 }
示例#2
0
 internal static string LoadString(string name, string cat)
 {
     using (var nodeKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(NodejsConstants.BaseRegistryKey))
     {
         using (var optionsKey = nodeKey.CreateSubKey(_optionsKey))
         {
             using (var categoryKey = optionsKey.CreateSubKey(cat))
             {
                 return(categoryKey.GetValue(name) as string);
             }
         }
     }
 }
示例#3
0
 internal static void SaveString(string name, string value, string cat)
 {
     using (var pythonKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(NodejsConstants.BaseRegistryKey))
     {
         using (var optionsKey = pythonKey.CreateSubKey(_optionsKey))
         {
             using (var categoryKey = optionsKey.CreateSubKey(cat))
             {
                 categoryKey.SetValue(name, value, Win32.RegistryValueKind.String);
             }
         }
     }
 }
 private void addOurFileExtensionsForDiffAndPeek(string parent)
 {
     using (RegistryKey root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration, true))
     {
         if (root != null)
         {
             using (RegistryKey key = root.OpenSubKey(parent, true))
             {
                 key.SetValue(EXTENSIONS, "");
             }
         }
     }
 }
 /// <summary>
 /// Get the color scheme that is applied to the configuration registry.
 /// </summary>
 public SchemeName GetAppliedColorScheme()
 {
     // The applied color scheme is stored in the configuration registry with the color theme information because
     // when the hive gets rebuilt during upgrades, we need to reapply the color scheme information.
     using var registryRoot = VSRegistry.RegistryRoot(
               _serviceProvider,
               __VsLocalRegistryType.RegType_Configuration,
               writable: false
               );
     using var itemKey = registryRoot.OpenSubKey(ColorSchemeApplierKey);
     return(itemKey is object
            ?(SchemeName)itemKey.GetValue(AppliedColorSchemeName)
                : default);
示例#6
0
        public static bool InstallDebugger(IMessageLogger msg, bool force = false)
        {
            try
            {
                if (CheckInstalled() && !force) //Check if the debugger is already installed
                {
                    return(true);
                }

                string location = typeof(MonoEngine).Assembly.Location;

                //Register the debugger assembly
                string regasm = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe";
                if (!Environment.Is64BitOperatingSystem)
                {
                    regasm = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe";
                }

                var p = new ProcessStartInfo(regasm, location);
                p.Verb = "runas";
                p.RedirectStandardOutput = true;
                p.UseShellExecute        = false;
                p.CreateNoWindow         = true;

                Process proc = Process.Start(p);
                proc.WaitForExit();

                if (proc.ExitCode != 0)
                {
                    throw new UnauthorizedAccessException();
                }

                //Add the regsitry stuff for VS
                using (RegistryKey config = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration))
                {
                    RegisterDebugEngine(location, config);
                }

                return(true);
            }
            catch (UnauthorizedAccessException)
            {
                msg.ErrorMessage("Unable to install " + DebuggerGuids.EngineName + " - Please run Visual Studio as administrator.", "Debugger installation");
            }
            catch (Exception ex)
            {
                msg.ErrorMessage("An error ocurred while installing " + DebuggerGuids.EngineName + ": \"" + ex.Message + "\"", "Debugger installation");
            }

            return(false);
        }
示例#7
0
 Guid FindGuid()
 {
     try
     {
         using (var settings = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration))
             using (var languages = settings.OpenSubKey("Languages"))
                 using (var intellisenseProviders = languages.OpenSubKey("IntellisenseProviders"))
                     using (var provider = intellisenseProviders.OpenSubKey(ProviderName))
                         return(new Guid(provider.GetValue("GUID").ToString()));
     }
     catch
     {
         return(Guid.Empty);
     }
 }
示例#8
0
        private static IRegistryKey OpenRegistry(bool writeable)
        {
            if (OverrideRegistryKey != null)
            {
                return(OverrideRegistryKey);
            }

            var root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writeable);

            var subKey = writeable
                ? root.CreateSubKey(RegistryPath)
                : root.OpenSubKey(RegistryPath);

            return((subKey != null) ? new RegistryKeyImpl(subKey) : null);
        }
            public void ApplyColorScheme(SchemeName schemeName, ImmutableArray <RegistryItem> registryItems)
            {
                using var registryRoot = VSRegistry.RegistryRoot(_serviceProvider, __VsLocalRegistryType.RegType_Configuration, writable: true);

                foreach (var item in registryItems)
                {
                    using var itemKey = registryRoot.CreateSubKey(item.SectionName);
                    itemKey.SetValue(item.ValueName, item.ValueData);
                }

                _workspace.SetOptions(_workspace.Options.WithChangedOption(ColorSchemeOptions.AppliedColorScheme, schemeName));

                // Broadcast that system color settings have changed to force the ColorThemeService to reload colors.
                NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, NativeMethods.WM_SYSCOLORCHANGE, wparam: IntPtr.Zero, lparam: IntPtr.Zero);
            }
示例#10
0
        /// <summary>
        /// Get the localized names of "Global", "Text Editor" and "Solution Explorer" scope.  I wish there was a
        /// prettier way of doing this.  However there is no API available which provides this information.  We need to directly
        /// query some registry values here
        /// </summary>
        private static bool TryGetMainScopeNames(IVsShell vsShell, out string globalScopeName, out string textEditorScopeName, out string solutionExplorerScopeName)
        {
            globalScopeName           = null;
            textEditorScopeName       = null;
            solutionExplorerScopeName = null;
            try
            {
                using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration, writable: false))
                {
                    if (rootKey is null)
                    {
                        return(false);
                    }

                    using (var keyBindingsKey = rootKey.OpenSubKey("KeyBindingTables"))
                    {
                        // For "Global".  The id in the registry here is incorrect for Vs 2010+
                        // so hard code the known value
                        if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{5efc7975-14bc-11cf-9b2b-00aa00573819}", 13018, out globalScopeName))
                        {
                            return(false);
                        }

                        // For "Text Editor".  Many locals don't define this key so it's still considered a success
                        // if we get only the global name.  Just fill in the default here
                        if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{8B382828-6202-11D1-8870-0000F87579D2}", null, out textEditorScopeName))
                        {
                            textEditorScopeName = DefaultTextEditorScopeName;
                        }

                        // The "Solution Explorer" scope is only relevant starting in VS2013.  By default it contains a lot of
                        // key bindings for '['.  If we can't find the real name just use the default.  We don't want its abscence
                        // to screw up other scopes
                        if (!TryGetKeyBindingScopeName(vsShell, keyBindingsKey, "{3AE79031-E1BC-11D0-8F78-00A0C9110057}", null, out solutionExplorerScopeName))
                        {
                            solutionExplorerScopeName = DefaultSolutionExplorerScopeName;
                        }
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#11
0
        private void TryRegisterAssembly()
        {
            try
            {
                RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(@"CLSID\{8BF3AB9F-3864-449A-93AB-E7B0935FC8F5}");

                if (regKey != null)
                {
                    return;
                }

                string location = typeof(DebuggedProcess).Assembly.Location;

                string regasm = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe";
                if (!Environment.Is64BitOperatingSystem)
                {
                    regasm = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe";
                }

                var p = new ProcessStartInfo(regasm, location);
                p.Verb = "runas";
                p.RedirectStandardOutput = true;
                p.UseShellExecute        = false;
                p.CreateNoWindow         = true;

                Process proc = Process.Start(p);
                while (!proc.HasExited)
                {
                    string txt = proc.StandardOutput.ReadToEnd();
                }

                using (RegistryKey config = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration))
                {
                    MonoRemoteDebuggerInstaller.RegisterDebugEngine(location, config);
                }
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show(
                    "Failed finish installation of MonoRemoteDebugger - Please run Visual Studio once als Administrator...",
                    "MonoRemoteDebugger", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
示例#12
0
        private bool CheckKey(string editor, string extension)
        {
            var  root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration);
            var  reg  = root.OpenSubKey("editors\\" + editor + "\\Extensions");
            bool Ok   = true;

            if (reg != null)
            {
                object value = reg.GetValue(extension);
                if (value is int && (int)value >= 0x42)
                {
                    Ok = false;
                }
                reg.Close();
            }
            return(Ok);
        }
示例#13
0
        public static bool IsTestAdapaterEnabled()
        {
            if (!checkedRegistryForTestAdapterEnabled)
            {
                using (var nodeKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(NodejsConstants.BaseRegistryKey))
                    using (var optionsKey = nodeKey.CreateSubKey("Options"))
                        using (var categoryKey = optionsKey.CreateSubKey("testing"))
                        {
                            // If the value is set to something we disable this testadapter
                            registryValueForTestAdapterEnabled = string.IsNullOrEmpty(categoryKey.GetValue("testadapter") as string);
                        }

                checkedRegistryForTestAdapterEnabled = true;
            }

            return(registryValueForTestAdapterEnabled);
        }
        bool ITextTemplatingEngineHost.LoadIncludeText(string requestFileName, out string content, out string location)
        {
            location = ((ITextTemplatingEngineHost)this).ResolvePath(requestFileName);

            if (File.Exists(location))
            {
                content = File.ReadAllText(location);

                return(true);
            }

            using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration))
                using (var includeFoldersKey = rootKey.OpenSubKey(@"TextTemplating\IncludeFolders\.tt"))
                {
                    foreach (var valueName in includeFoldersKey.GetValueNames())
                    {
                        var includeFolder = includeFoldersKey.GetValue(valueName) as string;

                        if (includeFolder == null)
                        {
                            continue;
                        }

                        location = Path.Combine(includeFolder, requestFileName);

                        if (File.Exists(location))
                        {
                            content = File.ReadAllText(location);

                            // Our implementation doesn't require respecting the CleanupBehavior custom directive, and since
                            // implementing a fallback custom directive processor would essencially force us to have two
                            // different versions of the EF Power Tools (one for VS 2010, another one for VS 2012) the simplest
                            // solution is to remove the custom directive from the in-memory copy of the ttinclude
                            content = content.Replace(@"<#@ CleanupBehavior Processor=""T4VSHost"" CleanupAfterProcessingTemplate=""true"" #>", "");

                            return(true);
                        }
                    }
                }

            location = string.Empty;
            content  = string.Empty;

            return(false);
        }
        internal static bool ShouldUseV3CdpDebugger()
        {
            var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false);

            try
            {
                object userDebuggerOption = userRegistryRoot.OpenSubKey("Debugger")?.GetValue("EnableJavaScriptMultitargetNodeDebug");
                if (userDebuggerOption is int optionVal)
                {
                    return(optionVal != 0);
                }
            }
            catch (Exception) { } // do nothing. proceed to trying the feature flag below.

            var featureFlagsService = (IVsFeatureFlags)ServiceProvider.GlobalProvider.GetService(typeof(SVsFeatureFlags));

            return(featureFlagsService is IVsFeatureFlags && featureFlagsService.IsFeatureEnabled("JavaScript.Debugger.V3CdpNodeDebugAdapter", false));
        }
示例#16
0
        /// <summary>
        /// Called after Visual Studio services are available, before the frame is created (this.Frame can be null)
        /// </summary>
        protected override void Initialize()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.package.Telemetry.TrackEvent(Constants.EventInitializePane);

            // Look up the value of WPF trace settings in the registry
            using (RegistryKey rootKey = VSRegistry.RegistryRoot(this, __VsLocalRegistryType.RegType_UserSettings, writable: true))
            {
                this.dataBindingOutputLevelKey = rootKey.CreateSubKey(Constants.DataBindingTraceKey, writable: true);
            }

            this.HookDataBindingTraceLevel();
            this.HookDebugEvents();
            this.WaitForDebugOutputTextBuffer();

            base.Initialize();
        }
示例#17
0
        /// <summary>
        /// Reads a boolean value specifying whether to show or not show the dialog
        /// </summary>
        /// <param name="registryKey">The key containing the value.</param>
        /// <returns>The value read. If the value cannot be read false is returned.</returns>
        internal static bool ReadDontShowAgainValue(string registryKey)
        {
            bool dontShowAgain = false;

            using (RegistryKey root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings))
            {
                if (root != null)
                {
                    using (RegistryKey key = root.OpenSubKey(GeneralSubKey))
                    {
                        int value = (int)key.GetValue(registryKey, 0);
                        dontShowAgain = (value != 0);
                    }
                }
            }

            return(dontShowAgain);
        }
示例#18
0
        protected System.Drawing.Color UpdateColorSetting(string name, System.Drawing.Color defaultColor)
        {
            using (var regKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings))
            {
                if (regKey == null)
                {
                    return(defaultColor);
                }

                using (var colorKey = regKey.OpenSubKey(PROP_LOCATION))
                {
                    if (colorKey == null)
                    {
                        return(defaultColor);
                    }

                    var prop = colorKey.GetValue(name) as string;
                    if (prop == null)
                    {
                        return(defaultColor);
                    }

                    try
                    {
                        BlackSpaceColorConverter cc = new BlackSpaceColorConverter();
                        object Obj = cc.ConvertFromString(prop);
                        if (Obj != null && Obj is System.Drawing.Color)
                        {
                            System.Drawing.Color color = (System.Drawing.Color)Obj;
                            if (!color.IsEmpty)
                            {
                                return(color);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        System.Console.WriteLine(e.Message);
                        return(defaultColor);
                    }
                    return(defaultColor);
                }
            }
        }
        public static IEnumerable <ColumnState> LoadSettings(string window, IEnumerable <ColumnState> defaultColumns)
        {
            var columns = new List <Tuple <int, ColumnState> >();

            using (var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: false))
            {
                using (var columnsSubKey = rootKey.OpenSubKey(CreateColumnsKey(window), writable: false))
                {
                    if (columnsSubKey == null)
                    {
                        return(defaultColumns);
                    }

                    foreach (var columnName in columnsSubKey.GetSubKeyNames())
                    {
                        using (var columnSubKey = columnsSubKey.OpenSubKey(columnName, writable: false))
                        {
                            if (columnSubKey == null)
                            {
                                continue;
                            }

                            var descendingSort = (int)columnSubKey.GetValue(ColumnSortDown, 1) != 0;
                            var sortPriority   = (int)columnSubKey.GetValue(ColumnSortPriority, 0);

                            var groupingPriority = (int)columnSubKey.GetValue(ColumnGroupingPriority, 0);

                            var columnOrder = (int)columnSubKey.GetValue(ColumnOrder, int.MaxValue);
                            var visibility  = (int)columnSubKey.GetValue(ColumnVisibility, 0) != 0;
                            var width       = (int)columnSubKey.GetValue(ColumnWidth, 20);

                            var state = new ColumnState2(columnName, visibility, width, sortPriority, descendingSort, groupingPriority);

                            columns.Add(new Tuple <int, ColumnState>(columnOrder, state));
                        }
                    }
                }
            }

            columns.Sort((a, b) => a.Item1 - b.Item1);

            return(columns.Select(a => a.Item2));
        }
示例#20
0
        private void InitializeRegistrySettings()
        {
            using (var textEditor = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey("Text Editor")) {
                using (var ironRubyKey = textEditor.CreateSubKey(RubyConstants.TextEditorSettingsRegistryKey)) {
                    object curValue;
                    curValue = ironRubyKey.GetValue("Insert Tabs");
                    if (curValue == null)
                    {
                        ironRubyKey.SetValue("Insert Tabs", 0);
                    }

                    curValue = ironRubyKey.GetValue("Indent Size");
                    if (curValue == null)
                    {
                        ironRubyKey.SetValue("Indent Size", 2);
                    }
                }
            }
        }
        public static bool SaveSettings(string window, IWpfTableControl control)
        {
            var columns = control.ColumnStates;

            using (var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true))
            {
                using (var columnsSubKey = rootKey.CreateSubKey(CreateColumnsKey(window)))
                {
                    if (columnsSubKey == null)
                    {
                        return(false);
                    }

                    for (var i = 0; i < columns.Count; i++)
                    {
                        var column = columns[i];

                        using (var columnSubKey = columnsSubKey.CreateSubKey(column.Name))
                        {
                            if (columnSubKey == null)
                            {
                                continue;
                            }

                            columnSubKey.SetValue(ColumnOrder, i, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnVisibility, column.IsVisible ? 1 : 0, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnWidth, (int)column.Width, RegistryValueKind.DWord);

                            columnSubKey.SetValue(ColumnSortDown, column.DescendingSort ? 1 : 0, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnSortPriority, column.SortPriority, RegistryValueKind.DWord);

                            if (column is ColumnState2 cs2)
                            {
                                columnSubKey.SetValue(ColumnGroupingPriority, cs2.GroupingPriority, RegistryValueKind.DWord);
                            }
                        }
                    }
                }
            }

            return(true);
        }
示例#22
0
 internal static string LoadString(string name, string cat)
 {
     using (var pythonKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(VSGeneroConstants.BaseRegistryKey))
     {
         if (pythonKey == null)
         {
             return(null);
         }
         using (var optionsKey = pythonKey.CreateSubKey(_optionsKey))
         {
             if (optionsKey == null)
             {
                 return(null);
             }
             using (var categoryKey = optionsKey.CreateSubKey(cat)) {
                 return(categoryKey?.GetValue(name) as string);
             }
         }
     }
 }
示例#23
0
 private static string LoadString(string name)
 {
     using (var pythonKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(VSGeneroConstants.BaseRegistryKey))
     {
         if (pythonKey == null)
         {
             return(null);
         }
         using (var refactorKey = pythonKey.CreateSubKey(RefactorKey))
         {
             if (refactorKey == null)
             {
                 return(null);
             }
             using (var renameKey = refactorKey.CreateSubKey(RenameKey))
             {
                 return(renameKey?.GetValue(name) as string);
             }
         }
     }
 }
示例#24
0
 private string LoadStringInternal(string name, string cat)
 {
     using (var regKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, true).CreateSubKey(_baseKey))
     {
         if (regKey == null)
         {
             return(null);
         }
         using (var optionsKey = regKey.CreateSubKey(_optionsKey))
         {
             if (optionsKey == null)
             {
                 return(null);
             }
             using (var categoryKey = optionsKey.CreateSubKey(cat))
             {
                 return(categoryKey?.GetValue(name) as string);
             }
         }
     }
 }
示例#25
0
        internal static bool ShouldUseV3CdpDebugger()
        {
            var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false);

            try
            {
                object userDebuggerOption = userRegistryRoot.OpenSubKey("Debugger")?.GetValue("EnableJavaScriptMultitargetDebugging");
                if (userDebuggerOption == null)
                {
                    return(false);
                }
                else
                {
                    return((int)userDebuggerOption != 0);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#26
0
        public static void TryRegisterAssembly()
        {
            // TODO move to AdapterRegistration.pkgdef
            // see https://github.com/microsoft/VSDebugAdapterHost/blob/master/src/sample/SampleDebugAdapter.VSIX/AdapterRegistration.pkgdef
            // see https://github.com/Microsoft/VSDebugAdapterHost/wiki
            // see https://github.com/microsoft/VSDebugAdapterHost/wiki/Packaging-a-VS-Code-Debug-Adapter-For-Use-in-VS
            RegistryKey regKey = Registry.ClassesRoot.OpenSubKey($@"CLSID\{{{DebugEngineGuids.EngineGuid.ToString()}}}");

            if (regKey != null)
            {
                return; // Already registered
            }
            string location = typeof(XamarinEngine).Assembly.Location;

            string regasm = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe";

            if (!Environment.Is64BitOperatingSystem)
            {
                regasm = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe";
            }

            var regasmProcessStartInfo = new ProcessStartInfo(regasm, location);

            regasmProcessStartInfo.Verb = "runas";
            regasmProcessStartInfo.RedirectStandardOutput = true;
            regasmProcessStartInfo.UseShellExecute        = false;
            regasmProcessStartInfo.CreateNoWindow         = true;

            System.Diagnostics.Process process = System.Diagnostics.Process.Start(regasmProcessStartInfo);
            while (!process.HasExited)
            {
                string txt = process.StandardOutput.ReadToEnd();
            }

            using (RegistryKey config = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration))
            {
                RegisterDebugEngine(location, config);
            }
        }
示例#27
0
            public async Task ApplyColorSchemeAsync(
                ColorSchemeName schemeName, ImmutableArray <RegistryItem> registryItems, CancellationToken cancellationToken)
            {
                await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                using var registryRoot = VSRegistry.RegistryRoot(_serviceProvider, __VsLocalRegistryType.RegType_Configuration, writable: true);

                foreach (var item in registryItems)
                {
                    using var itemKey = registryRoot.CreateSubKey(item.SectionName);
                    itemKey.SetValue(RegistryItem.ValueName, item.ValueData);
                    // Flush RegistryKeys out of paranoia
                    itemKey.Flush();
                }

                registryRoot.Flush();

                SetAppliedColorScheme(schemeName);

                // Broadcast that system color settings have changed to force the ColorThemeService to reload colors.
                NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, NativeMethods.WM_SYSCOLORCHANGE, wparam: IntPtr.Zero, lparam: IntPtr.Zero);
            }
示例#28
0
        static GCManager()
        {
            // Allow disabling SustainedLowLatency by setting the reg key value to 0
            System.Threading.Tasks.Task.Run(() =>
            {
                using (var root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings))
                {
                    if (root != null)
                    {
                        using var key     = root.OpenSubKey("Performance");
                        const string name = "SustainedLowLatencyDuration";
                        if (key != null && key.GetValue(name) != null && key.GetValueKind(name) == Microsoft.Win32.RegistryValueKind.DWord)
                        {
                            s_delayMilliseconds = (int)key.GetValue(name, s_delayMilliseconds);
                            return;
                        }
                    }
                }

                s_delayMilliseconds = DefaultDelayMilliseconds;
            });
        }
示例#29
0
        private void InitializeDefaultInterpreterWatcher(IServiceProvider serviceProvider)
        {
            RegistryKey userSettingsKey;

            if (serviceProvider != null)
            {
                userSettingsKey = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_UserSettings, false);
            }
            else
            {
                userSettingsKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, false);
            }
            using (userSettingsKey) {
                RegistryHive hive;
                RegistryView view;
                string       keyName;
                if (RegistryWatcher.GetRegistryKeyLocation(userSettingsKey, out hive, out view, out keyName))
                {
                    if (RegistryWatcher.Instance.TryAdd(
                            hive, view, keyName + "\\" + DefaultInterpreterOptionsCollection,
                            DefaultInterpreterRegistry_Changed,
                            recursive: false, notifyValueChange: true, notifyKeyChange: false
                            ) == null)
                    {
                        // DefaultInterpreterOptions subkey does not exist yet, so
                        // create it and then start the watcher.
                        SaveDefaultInterpreter();

                        RegistryWatcher.Instance.Add(
                            hive, view, keyName + "\\" + DefaultInterpreterOptionsCollection,
                            DefaultInterpreterRegistry_Changed,
                            recursive: false, notifyValueChange: true, notifyKeyChange: false
                            );
                    }
                }
            }
        }
示例#30
0
        /// <summary>
        /// Get the localized names of the scopes who's key bindings we find interesting.  This is
        /// a fairly unpretty way of doing this.  Yet it's the only known way to achieve this in
        /// Dev10.
        /// </summary>
        private HashSet <string> CreateImportantScopeSet()
        {
            try
            {
                using (var rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration, writable: false))
                {
                    using (var keyBindingsKey = rootKey.OpenSubKey("KeyBindingTables"))
                    {
                        var set = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

                        // For "Global".  The id in the registry here is incorrect for Dev10
                        // so hard code the known value
                        set.Add(GetKeyBindingScopeName(
                                    keyBindingsKey,
                                    "{5efc7975-14bc-11cf-9b2b-00aa00573819}",
                                    13018,
                                    "Global"));

                        // For "Text Editor"
                        set.Add(GetKeyBindingScopeName(
                                    keyBindingsKey,
                                    "{8B382828-6202-11D1-8870-0000F87579D2}",
                                    null,
                                    "Text Editor"));

                        // No scope is considered interesting as well
                        set.Add("");
                        return(set);
                    }
                }
            }
            catch (Exception)
            {
                return(CreateDefaultImportantScopeSet());
            }
        }