Inheritance: System.MarshalByRefObject, IDisposable
        internal PackageInfo(RegistryKey key)
        {
            PackageId = Path.GetFileName(key.Name);
            DisplayName = (string)key.GetValue("DisplayName");
            PackageRootFolder = (string)key.GetValue("PackageRootFolder");

            // walk the files...
            XamlFiles = new List<string>();
            JsFiles = new List<string>();
            WalkFiles(new DirectoryInfo(PackageRootFolder));

            // probe for a start page...
            var appKey = key.OpenSubKey("Applications");
            if (appKey != null)
            {
                using (appKey)
                {
                    foreach(var subAppName in appKey.GetSubKeyNames())
                    {
                        using (var subAppKey = appKey.OpenSubKey(subAppName))
                        {
                            if (subAppKey != null)
                            {
                                var start = (string)subAppKey.GetValue("DefaultStartPage");
                                if (!(string.IsNullOrEmpty(start)))
                                {
                                    FoundStartPage = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 public Skeinforge()
 {
     InitializeComponent();
     RegMemory.RestoreWindowPos("skeinforgeWindow", this);
     repetierKey = Registry.CurrentUser.CreateSubKey("Software\\Repetier");
     regToForm();
 }
Exemple #3
1
		static public void WriteToRegistry(RegistryKey RegHive, string RegPath, string KeyName, string KeyValue)
		{
			// Split the registry path
			string[] regStrings;
			regStrings = RegPath.Split('\\');
			// First item of array will be the base key, so be carefull iterating below
			RegistryKey[] RegKey = new RegistryKey[regStrings.Length + 1];
			RegKey[0] = RegHive;

			for( int i = 0; i < regStrings.Length; i++ )
			{
				RegKey[i + 1] = RegKey[i].OpenSubKey(regStrings[i], true);
				// If key does not exist, create it
				if (RegKey[i + 1] == null)
				{
					RegKey[i + 1] = RegKey[i].CreateSubKey(regStrings[i]);
				}
			}

			// Write the value to the registry
			try
			{
				RegKey[regStrings.Length].SetValue(KeyName, KeyValue);
			}
			catch (System.NullReferenceException)
			{
				throw(new Exception("Null Reference"));
			}
			catch (System.UnauthorizedAccessException)
			{
				throw(new Exception("Unauthorized Access"));
			}
		}
        protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de)
        {
            RegistryKey r = null;

            using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "{0}\\ShellEx\\{1}", ext, ShellExGuid)))
            {
                CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
            }

            if (r == null)
            {
                using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", ext, ShellExGuid)))
                {
                    CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
                }
            }

            if (r == null)
            {
                string type = CheckStringValue(form, rk, PerceivedType, de);

                using (r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InstalledUICulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", type, ShellExGuid), de))
                {
                    CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
                }
            }
        }
    /// <summary>
    /// 注册表操作器
    /// </summary>
    /// <param name="rootKey">根键</param>
    public RegistryOperator(string rootKey)
    {
      if (string.IsNullOrEmpty(rootKey))
        throw new ArgumentNullException("rootKey");

      switch (rootKey.ToUpperInvariant())
      {
        case "CLASSES_ROOT":
          _rootkey = Microsoft.Win32.Registry.ClassesRoot;
          break;
        case "CURRENT_USER":
          _rootkey = Microsoft.Win32.Registry.CurrentUser;
          break;
        case "LOCAL_MACHINE":
          _rootkey = Microsoft.Win32.Registry.LocalMachine;
          break;
        case "USERS":
          _rootkey = Microsoft.Win32.Registry.Users;
          break;
        case "CURRENT_CONFIG":
          _rootkey = Microsoft.Win32.Registry.CurrentConfig;
          break;
        case "PERFORMANCE_DATA":
          _rootkey = Microsoft.Win32.Registry.PerformanceData;
          break;
        default:
          _rootkey = Microsoft.Win32.Registry.CurrentUser;
          break;
      }
    }
 public void CopyFromRegistry(RegistryKey keyToSave)
 {
     if (keyToSave == null)
     {
         throw new ArgumentNullException("keyToSave");
     }
     this.ValueNames = keyToSave.GetValueNames();
     if (this.ValueNames == null)
     {
         this.ValueNames = new string[0];
     }
     this.Values = new object[this.ValueNames.Length];
     for (int i = 0; i < this.ValueNames.Length; i++)
     {
         this.Values[i] = keyToSave.GetValue(this.ValueNames[i]);
     }
     this.KeyNames = keyToSave.GetSubKeyNames();
     if (this.KeyNames == null)
     {
         this.KeyNames = new string[0];
     }
     this.Keys = new SerializableRegistryKey[this.KeyNames.Length];
     for (int j = 0; j < this.KeyNames.Length; j++)
     {
         this.Keys[j] = new SerializableRegistryKey(keyToSave.OpenSubKey(this.KeyNames[j]));
     }
 }
        private static void RegisterFile(string path, RegistryKey root)
        {
            try
            {
				string userPath = GetUserFilePath(Path.GetFileName(path));
				string assembly = Assembly.GetExecutingAssembly().Location;
                string folder = Path.GetDirectoryName(assembly).ToLowerInvariant();
                string file = Path.Combine(folder, path);

                if (!File.Exists(file))
                    return;

				File.Copy(file, userPath, true);

				using (RegistryKey key = root.OpenSubKey("JavaScriptLanguageService", true))
                {
                    if (key == null)
                        return;

                    key.SetValue("ReferenceGroups_WE", "Implicit (Web)|" + userPath + ";");
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
        /// <summary>
        /// Get framework version for specified SubKey
        /// </summary>
        /// <param name="parentKey"></param>
        /// <param name="subVersionName"></param>
        /// <param name="versions"></param>
        private static void GetDotNetVersion(RegistryKey parentKey, string subVersionName, IList<NetFrameworkVersionInfo> versions)
        {
            if (parentKey != null)
            {
                string installed = Convert.ToString(parentKey.GetValue("Install"));

                if (installed == "1")
                {
                    NetFrameworkVersionInfo versionInfo = new NetFrameworkVersionInfo();

                    versionInfo.VersionString = Convert.ToString(parentKey.GetValue("Version"));

                    var test = versionInfo.BaseVersion;

                    versionInfo.InstallPath = Convert.ToString(parentKey.GetValue("InstallPath"));
                    versionInfo.ServicePackLevel = Convert.ToInt32(parentKey.GetValue("SP"));

                    if (parentKey.Name.Contains("Client"))
                        versionInfo.FrameworkProfile = "Client Profile";
                    else if (parentKey.Name.Contains("Full"))
                        versionInfo.FrameworkProfile = "Full Profile";

                    if (!versions.Contains(versionInfo))
                        versions.Add(versionInfo);
                }
            }
        }
 // populates an options object from values stored in the registry
 private static void PopulateOptions(object options, RegistryKey key)
 {
     foreach (PropertyInfo propInfo in options.GetType().GetProperties())
     {
         if (propInfo.IsDefined(typeof(ApplyPolicyAttribute)))
         {
             object valueFromRegistry = key.GetValue(propInfo.Name);
             if (valueFromRegistry != null)
             {
                 if (propInfo.PropertyType == typeof(string))
                 {
                     propInfo.SetValue(options, Convert.ToString(valueFromRegistry, CultureInfo.InvariantCulture));
                 }
                 else if (propInfo.PropertyType == typeof(int))
                 {
                     propInfo.SetValue(options, Convert.ToInt32(valueFromRegistry, CultureInfo.InvariantCulture));
                 }
                 else if (propInfo.PropertyType == typeof(Type))
                 {
                     propInfo.SetValue(options, Type.GetType(Convert.ToString(valueFromRegistry, CultureInfo.InvariantCulture), throwOnError: true));
                 }
                 else
                 {
                     throw CryptoUtil.Fail("Unexpected type on property: " + propInfo.Name);
                 }
             }
         }
     }
 }
Exemple #10
1
 public AddinsKey Add(string name, RegistryKey rootPath, string registryPath)
 {
     AddinsKey newItem = new AddinsKey(_parent, name, rootPath, registryPath);
     _items.Add(newItem);
     _parent.StopFlag = false;
     return newItem;
 }
 /// <summary>
 /// Helper function to recursively delete a sub-key (swallows errors in the
 /// case of the sub-key not existing
 /// </summary>
 /// <param name="root">Root to delete key from</param>
 /// <param name="subKey">Name of key to delete</param>
 public static void DeleteSubKeyTree(RegistryKey root, string subKey)
 {
     // delete the specified sub-key if if exists (swallow the error if the
     // sub-key does not exist)
     try { root.DeleteSubKeyTree(subKey); }
     catch (ArgumentException) { }
 }
Exemple #12
1
        public ChatOptions()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
            m_reg = key.CreateSubKey("TwitchChatClient");

            m_iniReader = new IniReader("options.ini");

            IniSection section = m_iniReader.GetSectionByName("stream");
            if (section == null)
                throw new InvalidOperationException("Options file missing [Stream] section.");

            m_stream = section.GetValue("stream");
            m_user = section.GetValue("twitchname") ?? section.GetValue("user") ?? section.GetValue("username");
            m_oath = section.GetValue("oauth") ?? section.GetValue("pass") ?? section.GetValue("password");

            section = m_iniReader.GetSectionByName("highlight");
            List<string> highlights = new List<string>();
            if (section != null)
                foreach (string line in section.EnumerateRawStrings())
                    highlights.Add(DoReplacements(line.ToLower()));

            m_highlightList = highlights.ToArray();

            section = m_iniReader.GetSectionByName("ignore");
            if (section != null)

            m_ignore = new HashSet<string>((from s in section.EnumerateRawStrings()
                                            where !string.IsNullOrWhiteSpace(s)
                                            select s.ToLower()));
        }
Exemple #13
1
        public Form1()
        {
            InitializeComponent();

             			m_AppKey = Registry.CurrentUser.CreateSubKey( @"Software\GodComplex\AlbedoDatabaseGenerator" );
            m_ApplicationPath = System.IO.Path.GetDirectoryName( Application.ExecutablePath );
        }
        protected List<SoftwareDTOResponse> GetItemsFromRegistry(RegistryKey key, string path)
        {
            List<SoftwareDTOResponse> software = new List<SoftwareDTOResponse>();

            using (RegistryKey rk = key.OpenSubKey(path))
            {
                foreach (string skName in rk.GetSubKeyNames())
                {
                    using (RegistryKey sk = rk.OpenSubKey(skName))
                    {
                        try
                        {
                            SoftwareDTOResponse application = new SoftwareDTOResponse();
                            application.Label = sk.GetValue("DisplayName").ToString();
                            application.ModelName = application.Label;
                            application.Version = sk.GetValue("DisplayVersion").ToString();
                            application.Path = sk.GetValue("Publisher").ToString() +
                                               " - " +
                                               application.Label +
                                               " - " +
                                               application.Version;

                            software.Add(application);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            return software;
        }
Exemple #15
1
 public UninstallerObject(RegistryKey rootKey, string keyPath, string keyName)
 {
     using (RegistryKey hkKey = rootKey.OpenSubKey(keyPath, false))
     {
         string ApplicationName = hkKey.GetValue("DisplayName") as string;
         if (string.IsNullOrEmpty(ApplicationName))
         {
             ApplicationName = hkKey.GetValue("QuietDisplayName") as string;
         }
         if (string.IsNullOrEmpty(ApplicationName))
             ApplicationName = keyName;
         Objects[(int)UninstallerItemTypes.Application] = ApplicationName;
         Objects[(int)UninstallerItemTypes.Path] = hkKey.GetValue("InstallLocation") as string;
         Objects[(int)UninstallerItemTypes.Key] = keyName;
         Objects[(int)UninstallerItemTypes.Version] = hkKey.GetValue("DisplayVersion") as string;
         Objects[(int)UninstallerItemTypes.Publisher] = hkKey.GetValue("Publisher") as string;
         Objects[(int)UninstallerItemTypes.HelpLink] = hkKey.GetValue("HelpLink") as string;
         Objects[(int)UninstallerItemTypes.AboutLink] = hkKey.GetValue("URLInfoAbout") as string;
         ToolTipText = hkKey.GetValue("UninstallString") as string;
         Objects[(int)UninstallerItemTypes.Action] = ToolTipText;
         if (string.IsNullOrEmpty(ToolTipText))
         {
             ForegroundColor = Color.Gray;
         }
         else if (!string.IsNullOrEmpty(Path))
         {
             ForegroundColor = Color.Blue;
         }
     }
 }
Exemple #16
1
        /// <summary>
        /// 解压缩
        /// </summary>
        /// <param name="zipname">要解压的文件名</param>
        /// <param name="zippath">要解压的文件路径</param>
        public static void DeZip(string zipname, string zippath)
        {
            try
            {
                the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                the_rar = the_rar.Substring(1, the_rar.Length - 7);
                the_Info = " X " + zipname + " " + zippath;
                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
                the_Process.WaitForExit();

                the_Process.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public static string GetRegistryStringValue(RegistryKey baseKey, string strSubKey, string strValue)
 {
     object obj = null;
     string text = string.Empty;
     string result;
     try
     {
         RegistryKey registryKey = baseKey.OpenSubKey(strSubKey);
         if (registryKey == null)
         {
             result = null;
             return result;
         }
         obj = registryKey.GetValue(strValue);
         if (obj == null)
         {
             result = null;
             return result;
         }
         registryKey.Close();
         baseKey.Close();
     }
     catch (Exception ex)
     {
         text = ex.Message;
         result = null;
         return result;
     }
     result = obj.ToString();
     return result;
 }
 private static bool IsApplicationInKey(RegistryKey key, string applicationName)
 {
     return key.GetSubKeyNames()
         .Select(key.OpenSubKey)
         .Select(subkey => subkey.GetValue("DisplayName") as string)
         .Any(displayName => displayName != null && displayName.Contains(applicationName));
 }
 /// <summary>
 /// 获取注册表项的子节点,并将其添加到树形控件节点中
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="rootKey"></param>
 public void GetSubKey(TreeNodeCollection nodes, RegistryKey rootKey)
 {
     if (nodes.Count != 0) return;
     //获取项的子项名称列表
     string[] keyNames = rootKey.GetSubKeyNames();
     //遍历子项名称
     foreach (string keyName in keyNames)
     {
     try
     {
     //根据子项名称功能注册表项
     RegistryKey key = rootKey.OpenSubKey(keyName);
     //如果表项不存在,则继续遍历下一表项
     if (key == null) continue;
     //根据子项名称创建对应树形控件节点
     TreeNode TNRoot = new TreeNode(keyName);
     //将注册表项与树形控件节点绑定在一起
     TNRoot.Tag = key;
     //向树形控件中添加节点
     nodes.Add(TNRoot);
     }
     catch
     {
     //如果由于权限问题无法访问子项,则继续搜索下一子项
     continue;
     }
     }
 }
 public UninstallerDataObject(RegistryKey rootKey, string keyPath, string keyName)
     : base(keyName)
 {
     BasedInLocalMachine = (rootKey == Registry.LocalMachine);
     Refresh(rootKey, keyPath, keyName);
     ConstructionIsFinished = true;
 }
Exemple #21
0
        public Config()
        {
            appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + appName + "\\";

            if (! Directory.Exists(appDataDir))
            {
                try
                {
                    Directory.CreateDirectory(appDataDir);
                }
                catch
                {
                    Log.error("Не могу создать каталог \"" + appDataDir + "\".");
                }
            }

            RegistryKey software = Registry.CurrentUser.OpenSubKey("Software", true);
            options = software.CreateSubKey(appName);
            tempDir = Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.User) + "\\";

            if (!Directory.Exists(tempDir))
            {
                MessageBox.Show("Временный каталог не найден!");
                return;
            }
        }
Exemple #22
0
		public seemsForm()
        {
			InitializeComponent();

            ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional;

			this.Load += seems_Load;
			this.Resize += seems_Resize;
			this.LocationChanged += seems_LocationChanged;

			seemsRegistryKey = Registry.CurrentUser.OpenSubKey( seemsRegistryLocation );
			if( seemsRegistryKey != null )
				seemsRegistryKey.Close();

			recentFilesMenu = new MruStripMenu( recentFilesFileMenuItem, new MruStripMenu.ClickedHandler( recentFilesFileMenuItem_Click ), seemsRegistryLocation + "\\Recent File List", true );

            browseToFileDialog = new OpenDataSourceDialog();
			browseToFileDialog.InitialDirectory = "C:\\";

            DockPanelManager.RenderMode = DockPanelRenderMode.VisualStyles;

            manager = new Manager(dockPanel);

            Manager.GraphFormGotFocus += new GraphFormGotFocusHandler(Manager_GraphFormGotFocus);
            Manager.LoadDataSourceProgress += new LoadDataSourceProgressEventHandler(Manager_LoadDataSourceProgress);
		}
 private static void AddFoldersFromRegistryKey(RegistryKey hive, string key, Hashtable directories)
 {
     RegistryKey key2 = hive.OpenSubKey(key);
     string str = string.Empty;
     if (hive == Registry.CurrentUser)
     {
         str = "hkcu";
     }
     else if (hive == Registry.LocalMachine)
     {
         str = "hklm";
     }
     else
     {
         Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(false, "AssemblyFolder.AddFoldersFromRegistryKey expected a known hive.");
     }
     if (key2 != null)
     {
         foreach (string str2 in key2.GetSubKeyNames())
         {
             RegistryKey key3 = key2.OpenSubKey(str2);
             if (key3.ValueCount > 0)
             {
                 string path = (string) key3.GetValue("");
                 if (Directory.Exists(path))
                 {
                     string str4 = str + @"\" + str2;
                     directories[str4] = path;
                 }
             }
         }
     }
 }
		private static int ReadIntKeyValue(RegistryKey registryKey, string keyName, string valueName)
		{
			using (var key = registryKey.OpenSubKey(keyName))
			{
				return key == null ? 0 : (int)key.GetValue(valueName, 0);
			}
		}
 /// <summary>
 /// Renames a subkey of the passed in registry key since 
 /// the Framework totally forgot to include such a handy feature.
 /// </summary>
 /// <param name="regKey">The RegistryKey that contains the subkey 
 /// you want to rename (must be writeable)</param>
 /// <param name="subKeyName">The name of the subkey that you want to rename
 /// </param>
 /// <param name="newSubKeyName">The new name of the RegistryKey</param>
 /// <returns>True if succeeds</returns>
 public static bool RenameSubKey(RegistryKey parentKey,
     string subKeyName, string newSubKeyName)
 {
     CopyKey(parentKey, subKeyName, newSubKeyName);
     parentKey.DeleteSubKeyTree(subKeyName);
     return true;
 }
		public static Int32? GetDword( RegistryKey rk, string value, Int32? defaultValue = null ) {
			var result = rk.GetValue( value ) as Int32?;
			if( null == result && null != defaultValue ) {
				result = defaultValue;
			}
			return result;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Checks if a registry value exists.
		/// </summary>
		/// <param name="key">The base registry key of the key to check</param>
		/// <param name="subKey">Name of the group key, or string.Empty if there is no 
		/// groupKeyName.</param>
		/// <param name="regEntry">The name of the registry entry.</param>
		/// <param name="value">[out] value of the registry entry if it exists; null otherwise.</param>
		/// <returns><c>true</c> if the registry entry exists, otherwise <c>false</c></returns>
		/// ------------------------------------------------------------------------------------
		public static bool RegEntryExists(RegistryKey key, string subKey, string regEntry, out object value)
		{
			value = null;

            if (key == null)
                return false;

            if (string.IsNullOrEmpty(subKey))
			{
				value = key.GetValue(regEntry);
				if (value != null)
					return true;
				return false;
			}

			if (!KeyExists(key, subKey))
				return false;

			using (RegistryKey regSubKey = key.OpenSubKey(subKey))
			{
				Debug.Assert(regSubKey != null, "Should have caught this in the KeyExists call above");
				if (Array.IndexOf(regSubKey.GetValueNames(), regEntry) >= 0)
				{
					value = regSubKey.GetValue(regEntry);
					return true;
				}

				return false;
			}
		}
Exemple #28
0
 private static void AddFreddyToRegistry()
 {
     _key = Registry.CurrentUser.CreateSubKey("SpringIocQuickStartVariableSources");
     _key.SetValue("freddy_name", "Freddy Rumsen");
     _key.SetValue("freddy_age", 44, RegistryValueKind.DWord);
     _key.Flush();
 }
    public ISerializator this[ string subkey ]
    {
      get
      {
        if( m_subkeys.Contains( subkey ) == false )
        {
          // try to open key first
          if( m_key == null )
          {
            // create if no m_key
            CreateKeyByStorePath();
            m_key = ( RegistryKey )m_subkeys[ m_strStorePath ];
          }

          RegistryKey sub = m_key.OpenSubKey( subkey, true );
          
          if( sub == null )
          {
            sub = m_key.CreateSubKey( subkey );
            
            if( sub == null )
            {
              throw new ApplicationException( "Cannot create registy keys. Please check user permissions." );
            }
          }

          m_subkeys[ subkey ] = sub;
        }
        
        return new RegistrySerialize( (RegistryKey)m_subkeys[ subkey ], subkey );
      }
    }
 public RegistryKeyItem(RegistryKeyItem parent, string text)
     : base(parent)
 {
     _root = parent.Root;
     Text = text;
     Path = string.Concat(parent.Path, parent.Path != null ? "\\" : string.Empty, text);
 }
Exemple #31
0
        private void RegeisterPlugin()
        {
            Microsoft.Win32.RegistryKey AcadPluginKey = this.GetAcadAppKey(true);
            if (AcadPluginKey != null)
            {
                Microsoft.Win32.RegistryKey AcadPluginInspectorKey = AcadPluginKey.CreateSubKey(AppName);
                AcadPluginInspectorKey.SetValue("DESCRIPTION", "CSCECDEC DWG Library", Microsoft.Win32.RegistryValueKind.String);
                AcadPluginInspectorKey.SetValue("LOADCTRLS", 2, Microsoft.Win32.RegistryValueKind.DWord);
                AcadPluginInspectorKey.SetValue("LOADER", PluginPath, Microsoft.Win32.RegistryValueKind.String);
                AcadPluginInspectorKey.SetValue("MANAGED", 1, Microsoft.Win32.RegistryValueKind.DWord);

                AcadPluginKey.Close();
                AcadApp.ShowAlertDialog("写入注册表成功,之后插件将在CAD每次重启时自动加载");
            }
            else
            {
                AcadApp.ShowAlertDialog("写入注册表失败");
                AcadPluginKey.Close();
            }
        }
Exemple #32
0
        private static bool CheckSetting(string path, string section, string key)

        {
            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(path + "\\" + section, false);



            if (regKey != null)

            {
                if (regKey.GetValue(key) != null)
                {
                    return(true);
                }
            }



            return(false);
        }
Exemple #33
0
        /// <summary>
        /// Ermittelt ob eine es unter dem Angebenen Schlüssel bereits Instanzen (Unterschlüssel) gibt.
        /// </summary>
        /// <returns>Wenn Instanzen (Unterschlüssel) vorhanden sind, wird TRUE zurückgegeben.</returns>
        public bool hasInstances()
        {
            List <String> myreturn = new List <string>();

            try
            {
                Microsoft.Win32.RegistryKey keyName = this.rootkey.OpenSubKey(this._subkey);
                String[] Subkeys = keyName.GetSubKeyNames();

                if (Subkeys.Length > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
            }

            return(false);
        }
Exemple #34
0
 public static bool EnableDcom(string ComputerName, string Value)
 {
     Win.RegistryKey baseKey = null;
     Win.RegistryKey DCOMKey = null;
     try
     {
         baseKey = Win.RegistryKey.OpenRemoteBaseKey(Win.RegistryHive.LocalMachine, ComputerName);
         Console.WriteLine("[+] Successfully got handle to HKLM hive on host " + ComputerName);
         DCOMKey = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\Ole", true);
         Console.WriteLine("[+] Successfully opened DCOM key on host " + ComputerName);
         DCOMKey.SetValue("EnableDCOM", Value);
         Console.WriteLine("[+] Successfully created registry key value on host " + ComputerName);
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine($"[-] Error: {e.Message}");
         return(false);
     }
 }
Exemple #35
0
        private static void GetTVID()
        {
            string key_value = "NOT FOUND";

            try
            {
                Microsoft.Win32.RegistryKey registryKey64 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\TeamViewer");
                RegistryKey registryKey32 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TeamViewer");
                if (!OS.Is64Bit())
                {
                    key_value = Registry.GetValue(registryKey32.Name, "ClientID", "NOT FOUND").ToString();
                }
                else
                {
                    key_value = Registry.GetValue(registryKey64.Name, "ClientID", "NOT FOUND").ToString();
                }
            }
            catch (System.Exception) { tvid = 000000000; }
            tvid = Int32.Parse(key_value);
        }
Exemple #36
0
        private static void GetTVversion()
        {
            string key_value = "NOT FOUND";

            try
            {
                Microsoft.Win32.RegistryKey registryKey64 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\TeamViewer");
                RegistryKey registryKey32 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TeamViewer");
                if (!OS.Is64Bit())
                {
                    key_value = Registry.GetValue(registryKey32.Name, "Version", "NOT FOUND").ToString();
                }
                else
                {
                    key_value = Registry.GetValue(registryKey64.Name, "Version", "NOT FOUND").ToString();
                }
            }
            catch (System.Exception) { tvistallpath = "notinstalled"; }
            tvversion = key_value;
        }
Exemple #37
0
        private string GetJavaInstallationPath()
        {
            string environmentPath = Environment.GetEnvironmentVariable("JAVA_HOME");

            if (!string.IsNullOrEmpty(environmentPath))
            {
                return(environmentPath);
            }

            string javaKey = "SOFTWARE\\JavaSoft\\Java Runtime Environment\\";

            using (Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(javaKey))
            {
                string currentVersion = rk.GetValue("CurrentVersion").ToString();
                using (Microsoft.Win32.RegistryKey key = rk.OpenSubKey(currentVersion))
                {
                    return(key.GetValue("JavaHome").ToString());
                }
            }
        }
Exemple #38
0
        public static bool isAmdGpuClockToolInstalled()
        {
            string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

            using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
            {
                foreach (string subkey_name in key.GetSubKeyNames())
                {
                    using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                    {
                        var a = subkey.GetValue("DisplayName");
                        if (((a != null)? a.ToString():"") == "AMD GPU Clock Tool")
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 public void RemoveUserDSN(string p_strDSN)
 {
     m_intError = 0;
     m_strError = "";
     try
     {
         m_oCurrentUserRegKey = Registry.CurrentUser.OpenSubKey(ODBC_INI_REG_PATH + "\\ODBC Data Sources", true);
         m_oCurrentUserRegKey.DeleteValue(p_strDSN);
         Registry.CurrentUser.DeleteSubKeyTree(ODBC_INI_REG_PATH + "\\" + p_strDSN, false);
     }
     catch (Exception err)
     {
         m_intError = -1;
         m_strError = err.Message;
     }
     finally
     {
         m_oCurrentUserRegKey.Close();
     }
 }
Exemple #40
0
        private void toggle_startWindows_CheckedChanged(object sender, EventArgs e)
        {
            var Settingslist = JsonConvert.DeserializeObject <ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));

            if (toggle_startWindows.Checked)
            {
                Settingslist.startup = true;

                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                key.SetValue("ChatLogger", Program.ExecutablePath + @"\ChatLogger.exe");
            }
            else
            {
                Settingslist.startup = false;

                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                key.DeleteValue("ChatLogger", false);
            }
            File.WriteAllText(Program.SettingsJsonFile, JsonConvert.SerializeObject(Settingslist, Formatting.Indented));
        }
        private static Win32.RegistryKey GetTizenKeyPage()
        {
            Win32.RegistryKey rkey = null;

            try
            {
                rkey = Win32.Registry.CurrentUser.OpenSubKey(TizenVSKey,
                                                             Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                if (rkey == null)
                {
                    rkey = Win32.Registry.CurrentUser.CreateSubKey(TizenVSKey,
                                                                   Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                }
            }
            catch
            {
            }

            return(rkey);
        }
Exemple #42
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            string keyName = "Software\\Microsoft\\Internet Explorer\\PageSetup";

            using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(keyName, true))
            {
                if (key != null)
                {
                    object old_footer = key.GetValue("footer");
                    object old_header = key.GetValue("header");
                    key.SetValue("footer", "");
                    key.SetValue("header", "");
                    key.SetValue("margin_top", "0.75");
                    key.SetValue("margin_right", "0.75");
                    key.SetValue("margin_bottom", "0.75");
                    key.SetValue("margin_left", "0.75");
                    this.webBrowser1.ShowPrintDialog();
                }
            }
        }
Exemple #43
0
        /// <summary>
        /// 卸载时删除已注册的CAP文件
        /// 同时删除CAD 文件
        /// </summary>
        /// <param name="savedState"></param>
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);

            #region 卸载已注册的CAP文件
            RegistryKey capReg         = Registry.ClassesRoot.OpenSubKey(".cap");
            RegistryKey capFileTypeReg = Registry.ClassesRoot.OpenSubKey(".CA_FileType");

            if (capReg != null)
            {
                Registry.ClassesRoot.DeleteSubKeyTree(".cap");
            }
            if (capFileTypeReg != null)
            {
                Registry.ClassesRoot.DeleteSubKeyTree(".CA_FileType");
            }
            #endregion

            /// 重置AutoCAD菜单
            FileTypeRegister.ResetAutoCADMenu();

            #region  除Solidworks插件
            try
            {
                Microsoft.Win32.RegistryKey hklm = Microsoft.Win32.Registry.LocalMachine;
                Microsoft.Win32.RegistryKey hkcu = Microsoft.Win32.Registry.CurrentUser;

                string keyname = "SOFTWARE\\SolidWorks\\Addins\\{2eff6d31-932a-4191-ad00-1d705e27a64f}";
                hklm.DeleteSubKey(keyname);

                keyname = "Software\\SolidWorks\\AddInsStartup\\{2eff6d31-932a-4191-ad00-1d705e27a64f}";
                hkcu.DeleteSubKey(keyname);
            }
            catch (System.NullReferenceException nl)
            {
            }
            catch (System.Exception e)
            {
            }
            #endregion
        }
Exemple #44
0
        public static void GetExesByRegistry()
        {
            string[]      searchWords = { "steamapps\\common", "Origin Games", "Uplay", "Ubisoft Game Launcher\\games", "Epic Games", "GOG Galaxy\\Games", "Steam", "steam" };
            List <string> filepaths   = new List <string>();

            string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

            using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
            {
                foreach (string subkey_name in key.GetSubKeyNames())
                {
                    using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                    {
                        Console.WriteLine(subkey.GetValue("DisplayName"));
                        //Console.WriteLine(subkey.GetValue("InstallLocation"));

                        //foreach(string searchWord in searchWords)
                        //{
                        //    try
                        //    {
                        //        if (subkey.GetValue("InstallLocation").ToString().Contains(searchWord))
                        //        {
                        //            filepaths.Add(subkey.GetValue("InstallLocation").ToString());
                        //            continue;
                        //        }
                        //    }
                        //    catch(NullReferenceException e)
                        //    {

                        //    }
                        //}
                    }
                }

                Console.WriteLine("Printing Filepaths");
                foreach (string filepath in filepaths)
                {
                    Console.WriteLine(filepath);
                }
            }
        }
        public static string GetRegistryKey(string regPath)
        {
            Win32.RegistryKey rkey = GetTizenKeyPage();

            string returnValue = string.Empty;

            try
            {
                if (regPath != null)
                {
                    returnValue = rkey?.GetValue(regPath)?.ToString();
                }
            }
            catch
            {
            }

            rkey?.Close();

            return(returnValue);
        }
Exemple #46
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int currWidth = toolStripComboBox1.Width;
            int x         = toolStrip1.Items.OfType <ToolStripItem>().Sum(t => t.Width);

            toolStripComboBox1.Size = new Size(toolStrip1.Width - x + currWidth - 30, toolStripComboBox1.Height);
            key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
            // string currentKey = key.GetValue("OmaSelain.exe").ToString();
            //if (currentKey != "0")

            //  if (key.GetValue("OmaSelain.exe").ToString() != null)
            //if (key.GetValue="OmaSelain.exe);
            if (key != null)

            {
                key.SetValue("OmaSelain.exe", unchecked ((int)0x2af9), RegistryValueKind.DWord);
            }
            else
            {
            }
        }
Exemple #47
0
 public static bool RegExists(string hive, string path)
 {
     Microsoft.Win32.RegistryKey myKey = null;
     if (hive == "HKLM")
     {
         myKey = Registry.LocalMachine.OpenSubKey(path);
     }
     else if (hive == "HKU")
     {
         myKey = Registry.Users.OpenSubKey(path);
     }
     else
     {
         myKey = Registry.CurrentUser.OpenSubKey(path);
     }
     if (myKey is null)
     {
         return(false);
     }
     return(true);
 }
        public static string GetJavaInstallationPath()
        {
            var environmentPath = Environment.GetEnvironmentVariable("JAVA_HOME");

            if (!string.IsNullOrEmpty(environmentPath))
            {
                return(environmentPath);
            }

            var javaKey = "SOFTWARE\\JavaSoft\\Java Runtime Environmentx\\";

            using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
                using (var rk = hklm.OpenSubKey(javaKey))
                {
                    string currentVersion = rk?.GetValue("CurrentVersion").ToString();
                    using (Microsoft.Win32.RegistryKey key = rk?.OpenSubKey(currentVersion))
                    {
                        return(key?.GetValue("JavaHome").ToString());
                    }
                }
        }
Exemple #49
0
 /// <summary>
 /// 开机启动项
 /// </summary>
 /// <param name="Started">是否启动</param>
 /// <param name="name">启动值的名称</param>
 /// <param name="path">启动程序的路径 Application.ExecutablePath</param>
 public static void RunWhenStart(bool Started, string name, string path)
 {
     Microsoft.Win32.RegistryKey HKLM = Microsoft.Win32.Registry.LocalMachine;
     Microsoft.Win32.RegistryKey Run  = HKLM.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
     if (Started == true)
     {
         try {
             Run.SetValue(name, path);
             HKLM.Close();
         }
         catch { }
     }
     else
     {
         try {
             Run.DeleteValue(name);
             HKLM.Close();
         }
         catch { }
     }
 }
        public string getProjectPathFromRegistry()
        {
            try
            {
                CheckRegistry();
                var rkS = Registry.CurrentUser.OpenSubKey("Software", true);
                if (rkS == null)
                {
                    throw new System.NotImplementedException();
                }

                Microsoft.Win32.RegistryKey rk = rkS.OpenSubKey("pvdesktop", true);
                if (rk.GetValue("ProjectPath").ToString().Length > 0)
                {
                    //txtProjectPath.Text = rk.GetValue("ProjectPath").ToString();
                    return(rk.GetValue("ProjectPath").ToString());
                }
            }
            catch { return(""); }
            return("");
        }
Exemple #51
0
 /// <summary>
 /// 写注册表值(通用函数)
 /// </summary>
 public static void WriteRegValue(string subKey, string sName, string sValue, RegistryValueKind kind)
 {
     try
     {
         using (Microsoft.Win32.RegistryKey root = Registry.LocalMachine)
         {
             using (Microsoft.Win32.RegistryKey soft = root.OpenSubKey(subKey))
             {
                 if (soft != null)
                 {
                     if (sName != null && sValue != null)
                     {
                         soft.SetValue(sName, sValue, kind);
                     }
                 }
             }
         }
     }
     catch
     { }
 }
Exemple #52
0
        public void PersistImplant()
        {
            Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
                ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            string currfile = System.Reflection.Assembly.GetExecutingAssembly().Location;
            rk.SetValue(Path.GetFileName(currfile), currfile);
            string src = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            string dest = "%APPDATA%" + System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;
            System.IO.File.Copy(src, dest);
            try
            {
                cmd("schtasks.exe /create /tn hspintsdk /tr %APPDATA/MicrosoftUpdate/winternals.exe /SC hourly /mo 1");
            }
            catch (Exception)
            {
                //exception ignored
            }

                
        }
Exemple #53
0
        static void GetJavaInstallationPath()
        {
            try
            {
                string environmentPath = Environment.GetEnvironmentVariable("JAVA_HOME");
                if (!string.IsNullOrEmpty(environmentPath))
                {
                    folderJava = environmentPath;
                }

                string javaKey = "SOFTWARE\\JavaSoft\\Java Development Kit\\";
                using (Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(javaKey))
                {
                    string currentVersion = rk.GetValue("CurrentVersion").ToString();
                    using (Microsoft.Win32.RegistryKey key = rk.OpenSubKey(currentVersion))
                    {
                        folderJava = key.GetValue("JavaHome").ToString();
                    }
                }
            }catch (Exception e) { };
        }
Exemple #54
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(
                "スタートアップに登録しますか?\n" +
                "レジストリに書き込みます。\n\n" +
                "キー = HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\n" +
                "名前 = " + Application.ProductName + "\n" +
                "値 = " + Application.ExecutablePath,
                "スタートアップ登録",
                MessageBoxButtons.OKCancel,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2
                );

            if (result == DialogResult.OK)
            {
                try
                {
                    //レジストリ(スタートアップ)に登録する
                    //Runキーを開く
                    Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(
                        @"Software\Microsoft\Windows\CurrentVersion\Run");

                    //値の名前に製品名、値のデータに実行ファイルのパスを指定し、書き込む
                    regkey.SetValue(Application.ProductName, Application.ExecutablePath);

                    //閉じる
                    regkey.Close();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(
                        "以下の例外が発生しました\nException: " + ee.Message + "\nレジストリへのアクセス許可がない可能性があります。",
                        "エラー",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
        }
Exemple #55
0
        private string[] ReadTrialDate()
        {
            Microsoft.Win32.RegistryKey start       = Microsoft.Win32.Registry.LocalMachine;
            Microsoft.Win32.RegistryKey programName = start.OpenSubKey(REGISTRY_SECTION_64BITS);
            string[] nothing = { "" };

            if (programName == null)
            {
                programName = start.OpenSubKey(REGISTRY_SECTION_32BITS);
            }
            else
            {
                if (programName.GetValue(TRIAL_DATE_REG_NAME) == null)
                {
                    programName.Close();
                    programName = start.OpenSubKey(REGISTRY_SECTION_32BITS);        // change to 32bits if not found in 64bits
                }
            }

            if (programName != null)
            {
                object value = "";
                if ((value = programName.GetValue(TRIAL_DATE_REG_NAME)) != null)
                {
                    string   str  = Decrypt(value.ToString(), TRIAL_DATE_KEY);
                    string[] date = str.Split('/');
                    programName.Close();
                    return(date);
                }
                else
                {
                    programName.Close();
                    return(nothing);
                }
            }
            else
            {
                return(nothing);
            }
        }
        public static void firefox(string url)//指定浏览器为火狐
        {
            bool        flag         = false;
            RegistryKey registryKey3 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe");


            if (registryKey3 == null)
            {
                flag = false;
            }
            else
            {
                string[] subKeyNames = registryKey3.GetValueNames();
                for (int i = 0; i < subKeyNames.Length; i++)
                {
                    string name = subKeyNames[i];
                    Microsoft.Win32.RegistryKey registryKey2 = registryKey3.OpenSubKey(name);
                    object value = registryKey2.GetValue("Path");
                    if (value != null)
                    {
                        if (value.ToString().Contains("Mozilla Firefox"))
                        {
                            flag = true;
                            ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("firefox.exe"), new StringBuilder(url), new StringBuilder(""), 1);
                        }
                    }
                }
            }

            if (!flag)
            {
                LinkMessageBox lmb = new LinkMessageBox();
                lmb.ShowDialog();
                //MessageBox.Show("当前系统未安装火狐浏览器,清先安装火狐浏览器,下载地址:http://www.firefox.com.cn/", "提示信息");
            }
            else
            {
                ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("firefox.exe"), new StringBuilder(url), new StringBuilder(""), 1);
            }
        }
Exemple #57
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ArrayList GetInstalledAppsWithVersion()
        {
            ArrayList list = new ArrayList();

            string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

            using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
            {
                foreach (string subkeyName in key.GetSubKeyNames())
                {
                    using (RegistryKey subkey = key.OpenSubKey(subkeyName))
                    {
                        object oName    = subkey.GetValue("DisplayName");
                        object oVersion = subkey.GetValue("DisplayVersion");

                        string name    = "";
                        string version = "";

                        if (oName is string)
                        {
                            name = oName.ToString();

                            if (name != "")
                            {
                                if (oVersion is string)
                                {
                                    version = oVersion.ToString();
                                }

                                Entry entry = new Entry(name, version);
                                list.Add(entry);
                            }
                        }
                    }
                }
            }

            return(list);
        }
Exemple #58
0
 public Boolean testPython()
 {
     using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
     {
         foreach (string subkey_name in key.GetSubKeyNames())
         {
             using (RegistryKey subkey = key.OpenSubKey(subkey_name))
             {
                 String tempname = "";
                 if (subkey.GetValue("DisplayName") != null)
                 {
                     tempname = subkey.GetValue("DisplayName").ToString();
                 }
                 if (tempname.ToLower().Contains("python"))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public List <string> GetInstance()
 {
     if (appList == null)
     {
         appList = new List <string>();
         string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
         using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
         {
             foreach (string subkey_name in key.GetSubKeyNames())
             {
                 using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                 {
                     if (subkey.GetValue("DisplayName") != null)
                     {
                         appList.Add(subkey.GetValue("DisplayName").ToString());
                     }
                 }
             }
         }
     }
     return(appList);
 }
        public override bool GetOracleHome(out string oracleHome, out string errMsg)
        {
            oracleHome = _oraHome;
            errMsg     = "";

            if (string.IsNullOrEmpty(_oraHome) == false)
            {
                return(true);
            }


            Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine;
            RegistryKey key = FindSubKey(reg, "ORACLE INSTANT CLIENT");

            if (key == null)
            {
                errMsg = "未安装oracle";
                return(false);
            }

            object orahome = FindRegValue(key, "UNINSTALLSTRING");

            if (orahome == null)
            {
                errMsg = "未能找到ORACLE主目录";
                return(false);
            }

            oracleHome = orahome.ToString();

            int index = oracleHome.LastIndexOf('\\');

            if (index >= 0)
            {
                oracleHome = oracleHome.Substring(0, index);
            }
            _oraHome = oracleHome;
            return(true);
        }