Exemplo n.º 1
0
        public static string GetRegKeyOwner(RegistryKey runkey)
        {
            string owner = string.Empty;

            try
            {
                System.Security.AccessControl.RegistrySecurity regSec = runkey.GetAccessControl();
                owner = regSec.GetOwner(typeof(NTAccount)).ToString();
            }
            catch (Exception)
            {
            }
            return(owner);
        }
Exemplo n.º 2
0
        public static string GetMachineRegKeyOwner(string runkey, bool is64, out string regModified)
        {
            regModified = string.Empty;
            RegistryKey basekey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, is64 == true ? RegistryView.Registry64 : RegistryView.Registry32);
            RegistryKey subkey  = basekey.OpenSubKey(runkey);
            string      owner   = string.Empty;

            try
            {
                if (subkey != null)
                {
                    System.Security.AccessControl.RegistrySecurity regSec = subkey.GetAccessControl();
                    owner = regSec.GetOwner(typeof(NTAccount)).ToString();
                    try
                    {
                        DateTime regMod = RegistryModified.lastWriteTime(subkey);
                        regModified = regMod.ToUniversalTime().ToString(DBManager.DateTimeFormat);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (basekey != null)
                {
                    basekey.Close();
                }
                if (subkey != null)
                {
                    subkey.Close();
                }
            }
            return(owner);
        }