public static string GetMsBuildPath(IServiceProvider serviceProvider, string version) { string msBuildPath = null; using (RegistryKey root = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_Configuration, false)) { // Get the value from the registry using (RegistryKey vsKey = root.OpenSubKey("MSBuild", false)) { msBuildPath = (string)vsKey.GetValue("MSBuildBinPath", null); } } if (!string.IsNullOrEmpty(msBuildPath)) { return(msBuildPath); } // The path to MSBuild was not found in the VisualStudio's registry hive, so try to // find it in the new MSBuild hive. string registryPath = string.Format(CultureInfo.InvariantCulture, "Software\\Microsoft\\MSBuild\\ToolsVersions\\{0}", version); using (Microsoft.Win32.RegistryKey msbuildKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryPath, false)) { msBuildPath = (string)msbuildKey.GetValue("MSBuildToolsPath", null); } if (string.IsNullOrEmpty(msBuildPath)) { string error = SR.GetString(SR.ErrorMsBuildRegistration, CultureInfo.CurrentUICulture); throw new FileLoadException(error); } return(msBuildPath); }
internal static RegisteredProjectType CreateRegisteredProjectType(Guid projectTypeGuid) { RegisteredProjectType registederedProjectType = null; using (RegistryKey rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { if (rootKey == null) { return(null); } string projectPath = "Projects\\" + projectTypeGuid.ToString("B"); using (RegistryKey projectKey = rootKey.OpenSubKey(projectPath)) { if (projectKey == null) { return(null); } registederedProjectType = new RegisteredProjectType(); registederedProjectType.DefaultProjectExtensionValue = projectKey.GetValue(DefaultProjectExtension) as string; registederedProjectType.ProjectTemplatesDirValue = projectKey.GetValue(ProjectTemplatesDir) as string; registederedProjectType.WizardTemplatesDirValue = projectKey.GetValue(WizardsTemplatesDir) as string; registederedProjectType.PackageGuidValue = new Guid(projectKey.GetValue(Package) as string); } } return(registederedProjectType); }
static Hashtable GetEditors(IServiceProvider site) { if (EditorFactory.editors != null) { return(EditorFactory.editors); } Hashtable editors = new Hashtable(); using (RegistryKey rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { if (rootKey != null) { RegistryKey editorsKey = rootKey.OpenSubKey("Editors", false); if (editorsKey != null) { using (editorsKey) { foreach (string editorGuid in editorsKey.GetSubKeyNames()) { Guid guid = GetGuid(editorGuid); using (RegistryKey editorKey = editorsKey.OpenSubKey(editorGuid, false)) { object value = editorKey.GetValue(null); string name = (value != null) ? value.ToString() : editorGuid.ToString(); RegistryKey extensions = editorKey.OpenSubKey("Extensions", false); if (extensions != null) { foreach (string s in extensions.GetValueNames()) { if (!string.IsNullOrEmpty(s)) { EditorInfo ei = new EditorInfo(); ei.Name = name; ei.Guid = guid; object obj = extensions.GetValue(s); if (obj is int) { ei.Priority = (int)obj; } string ext = (s == "*") ? s : "." + s; AddEditorInfo(editors, ext, ei); } } } } } } } } } return(EditorFactory.editors = editors); }
/// <include file='doc\PropertySheet.uex' path='docs/doc[@for="LanguagePreferences.Init"]/*' /> public virtual void Init() { using (RegistryKey key = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { if (key != null) { InitMachinePreferences(key, name); } } using (RegistryKey key = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings)) { if (key != null) { InitUserPreferences(key, name); } } Connect(); }
internal override void ReadValues() { base.ReadValues(); object value = null; // Set default values var reg = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings); if (reg != null) { var key = reg.OpenSubKey("ApplicationPrivateSettings\\TextEditor\\XSharp"); if (key != null) { value = key.GetValue("CompleteFunctions"); } } if (value == null) { tbChars.Value = 4; checkbuttons(true); } }
static StringDictionary GetLanguageExtensions(IServiceProvider site) { if (EditorFactory.languageExtensions != null) { return(EditorFactory.languageExtensions); } StringDictionary extensions = new StringDictionary(); using (RegistryKey rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) { if (rootKey != null) { string relpath = "Languages\\File Extensions"; using (RegistryKey key = rootKey.OpenSubKey(relpath, false)) { if (key != null) { foreach (string ext in key.GetSubKeyNames()) { using (RegistryKey extkey = key.OpenSubKey(ext, false)) { if (extkey != null) { string fe = ext; string guid = extkey.GetValue(null) as string; // get default value if (!extensions.ContainsKey(fe)) { extensions.Add(fe, guid); } } } } } } } } return(EditorFactory.languageExtensions = extensions); }