Ejemplo n.º 1
0
        private void SearchOcxReg()
        {
            using (StreamReader file = File.OpenText(@".\JsonFiles\RegOcx.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                OcxRootDto     ocxRoot    = (OcxRootDto)serializer.Deserialize(file, typeof(OcxRootDto));

                RegistryKey OurKey;
                OurKey = Registry.ClassesRoot;

                foreach (OcxDto ocx in ocxRoot.Values)
                {
                    RegistryKey subKey = OurKey.OpenSubKey(ocxRoot.Subkey);

                    int row = dataGridView1.Rows.Add("OCX", ocx.Classe, ocx.Arquivo);
                    if (subKey.GetSubKeyNames().ToList().IndexOf(ocx.Classe) >= 0)
                    {
                        dataGridView1.Rows[row].Cells[3].Value = Resource1.Ok;
                    }
                    else
                    {
                        dataGridView1.Rows[row].Cells[3].Value = Resource1.NotOk;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        } // RegGetValue()

        public Boolean RegSetValue(string myRegTopKey, string myRegPath, string myRegKey, Object myValue)
        {
            // Local variables
            RegistryKey OurKey;
            RegistryKey OurKey2;
            Boolean     RetVal;

            OurKey = GetKeyClass(myRegTopKey);

            // Open the Sub Key
            OurKey2 = OurKey.OpenSubKey(myRegPath, true);
            if (OurKey2 == null)
            {
                // Create the new path.
                OurKey2 = OurKey.CreateSubKey(myRegPath);
                OurKey2 = OurKey.OpenSubKey(myRegPath, true);
            }

            // Return the Value
            try
            {
                RetVal = true;
                OurKey2.SetValue(myRegKey, myValue);
            }
            catch //(Exception e)
            {
                RetVal = false;
            }
            //OurKey.Close();
            OurKey  = null;
            OurKey2 = null;
            return(RetVal);
        } // RegSetValue()
Ejemplo n.º 3
0
        private void SearchDelphiPkgReg()
        {
            using (StreamReader file = File.OpenText(@".\JsonFiles\RegDelphiPackages.json"))
            {
                JsonSerializer       serializer       = new JsonSerializer();
                DelphiPackageRootDto delphiPackageReg = (DelphiPackageRootDto)serializer.Deserialize(file, typeof(DelphiPackageRootDto));

                RegistryKey OurKey;
                if (delphiPackageReg.RootRegistry == "HKEY_CURRENT_USER")
                {
                    OurKey = Registry.CurrentUser;
                }
                else
                {
                    OurKey = Registry.LocalMachine;
                }

                foreach (DelphiPackageDto pkg in delphiPackageReg.Packages)
                {
                    RegistryKey subKey = OurKey.OpenSubKey(delphiPackageReg.Subkey);

                    int row = dataGridView1.Rows.Add("Delphi Package", pkg.Package, pkg.Description);
                    if (subKey.GetValueNames().ToList().IndexOf(pkg.Package) >= 0)
                    {
                        dataGridView1.Rows[row].Cells[3].Value = Resource1.Ok;
                    }
                    else
                    {
                        dataGridView1.Rows[row].Cells[3].Value = Resource1.NotOk;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public Object RegGetValue(string myRegTopKey, string myRegPath, string myRegKey)
        {
            // Local variables
            RegistryKey OurKey;
            string      myValue;

            OurKey = GetKeyClass(myRegTopKey);

            // Open the Sub Key
            OurKey = OurKey.OpenSubKey(myRegPath, true);
            if (OurKey == null)
            {
                myValue = "";
            }
            else
            {
                // Return the Value
                try
                {
                    Object myObject = OurKey.GetValue(myRegKey, "");
                    if (myObject == null)
                    {
                        myValue = "";
                    }
                    else
                    {
                        myValue = myObject.ToString();
                    }
                    OurKey.Close();
                    OurKey = null;
                }
                catch // (Exception e)
                {
                    myValue = "";
                }
            }
            return(myValue);
        } // RegGetValue()