Thinktecture.Tools.Web.Services.Wscf.Environment.RegistryHelper.WriteKey C# (CSharp) 메소드

WriteKey() 공개 메소드

public WriteKey ( string KeyName, object Value ) : bool
KeyName string
Value object
리턴 bool
        public bool WriteKey(string KeyName, object Value)
        {
            try
            {
                RegistryKey rk = baseRegistryKey ;
                RegistryKey sk1 = rk.CreateSubKey(subKey);
                sk1.SetValue(KeyName.ToUpper(), Value);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

Usage Example

예제 #1
0
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
            // BDS 13-11-2006
            // Instead of simply restoring the originalPathRegValue stored during the
            // installation now we read the installDir from the state saver and
            // replace it in the PATH stored in the registry. This will not damage
            // the other entries in the PATH variable.
            string origRegValue = (string)savedState["OriginalPathRegValue"];
            string installDir   = (string)savedState["InstallDir"];

            RegistryHelper registry = new RegistryHelper();

            registry.BaseRegistryKey = Registry.LocalMachine;
            registry.SubKey         += @"System\CurrentControlSet\Control\Session Manager\Environment";
            string currentPath = registry.ReadKey("PATH");

            if (currentPath != null && currentPath.Length > 0)
            {
                if (installDir != null && installDir.Length > 0)
                {
                    registry.WriteKey("PATH", currentPath.Replace(";" + installDir, ""));
                }
            }

            EnvironmentHelper.BroadCast();

            try
            {
                // Remove the registry entry.
                Registry.LocalMachine.DeleteSubKey(RegistrySubKey, false);

                // Remove the .addin file.
                string addinFile = (string)savedState[@"AddinFilePath"];

                if (addinFile != null && File.Exists(addinFile))
                {
                    File.Delete(addinFile);
                }
            }
            catch (SecurityException)
            {
                MessageBox.Show(@"You must have write permission to the HKEY_LOCAL_MACHINE registry key in order to uninstall this software.");
                throw new InstallException(@"Access denied.");
            }
            catch
            {
                throw new InstallException(@"Unknown error.");
            }
        }
All Usage Examples Of Thinktecture.Tools.Web.Services.Wscf.Environment.RegistryHelper::WriteKey