Exemplo n.º 1
0
        private static string GetDataDirFromRegistry(string path, string valueName, Session session)
        {
            string dataPathKey    = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" + path;
            string dataPathKeyWow = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" + path;

            string projPath = "";

            try
            {
                if (RegistryU.KeyExists(dataPathKey))
                {
                    projPath = RegistryU.GetKey("HKLM", "SOFTWARE\\" + path).GetValue(valueName).ToString();
                }
                if (RegistryU.KeyExists(dataPathKeyWow))
                {
                    projPath = RegistryU.GetKey("HKLM", "SOFTWARE\\Wow6432Node\\" + path).GetValue(valueName).ToString();
                }
            }
            catch (Exception ex)
            {
                session.Log(ex.Message);
            }
            return(projPath);
        }
Exemplo n.º 2
0
        public static ActionResult DeleteVersionNumberFromRegistry(Session sessionb)
        {
            //Referenced by CustomAction DeleteRegistryVersionNumber
            string versionKeyPath = sessionb["REGISTRYVERSIONKEY"];
            string versionKeyWow  = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" + versionKeyPath + "\\";
            string versionKey     = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" + versionKeyPath + "\\";

            try
            {
                if (RegistryU.KeyExists(versionKey))
                {
                    RegistryU.DelKey(versionKey);
                }
                if (RegistryU.KeyExists(versionKeyWow))
                {
                    RegistryU.DelKey(versionKeyWow);
                }
            }
            catch (Exception e)
            {
                sessionb.Log("Exception occured while deleting a registry key." + e.Message);
            }
            return(ActionResult.Success);
        }