Thinktecture.Tools.Web.Services.Wscf.Environment.RegistryHelper.ReadKey C# (CSharp) Method

ReadKey() public method

public ReadKey ( string KeyName ) : string
KeyName string
return string
        public string ReadKey(string KeyName)
        {
            RegistryKey rk = baseRegistryKey ;
            RegistryKey sk1 = rk.OpenSubKey(subKey);

            if ( sk1 == null )
            {
                return null;
            }
            else
            {
                try
                {
                    return (string)sk1.GetValue(KeyName.ToUpper());
                }
                catch (Exception)
                {
                    return null;
                }
            }
        }

Usage Example

Esempio n. 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::ReadKey