ReadIntFromKey() public static method

public static ReadIntFromKey ( RegistryKey rootKey, string keyName, string valueName ) : int
rootKey Microsoft.Win32.RegistryKey
keyName string
valueName string
return int
コード例 #1
0
        private void LoadFromKey(RegistryKey key)
        {
            string name = key.GetValue(null) as string;

            if (!String.IsNullOrWhiteSpace(name))
            {
                Name = COMUtilities.DemangleWinRTName(name.ToString());
                CacheIidToName(Iid, Name);
            }
            else
            {
                Name = Iid.FormatGuidDefault();
            }

            ProxyClsid = COMUtilities.ReadGuidFromKey(key, "ProxyStubCLSID32", null);
            NumMethods = COMUtilities.ReadIntFromKey(key, "NumMethods", null);

            if (NumMethods < 3)
            {
                NumMethods = 3;
            }

            TypeLib        = COMUtilities.ReadGuidFromKey(key, "TypeLib", null);
            TypeLibVersion = COMUtilities.ReadStringFromKey(key, "TypeLib", "Version");
            Base           = COMUtilities.ReadStringFromKey(key, "BaseInterface", null);
            if (Base.Length == 0)
            {
                Base = "IUnknown";
            }
        }
コード例 #2
0
        private void LoadFromKey(RegistryKey key)
        {
            object name = key.GetValue(null);

            if ((name != null) && (name.ToString().Length > 0))
            {
                Name = name.ToString();
            }
            else
            {
                Name = String.Format("{{{0}}}", Iid.ToString());
            }

            ProxyClsid = COMUtilities.ReadGuidFromKey(key, "ProxyStubCLSID32", null);
            NumMethods = COMUtilities.ReadIntFromKey(key, "NumMethods", null);

            if (NumMethods < 3)
            {
                NumMethods = 3;
            }

            TypeLib        = COMUtilities.ReadGuidFromKey(key, "TypeLib", null);
            TypeLibVersion = COMUtilities.ReadStringFromKey(key, "TypeLib", "Version");

            Base = COMUtilities.ReadStringFromKey(key, "BaseInterface", null);
            if (Base.Length == 0)
            {
                Base = "IUnknown";
            }
        }
コード例 #3
0
 private void LoadFromKey(RegistryKey key)
 {
     Clsid          = COMUtilities.ReadGuidFromKey(key, null, "CLSID");
     ActivationType = (ActivationType)COMUtilities.ReadIntFromKey(key, null, "ActivationType");
     TrustLevel     = (TrustLevel)COMUtilities.ReadIntFromKey(key, null, "TrustLevel");
     Threading      = COMUtilities.ReadIntFromKey(key, null, "Threading");
     DllPath        = COMUtilities.ReadStringFromKey(key, null, "DllPath");
     Server         = COMUtilities.ReadStringFromKey(key, null, "Server");
     Permissions    = string.Empty;
     byte[] permissions = key.GetValue("Permissions", new byte[0]) as byte[];
     Permissions = COMSecurity.GetStringSDForSD(permissions);
 }
コード例 #4
0
 private void LoadFromKey(RegistryKey key)
 {
     IdentityType   = (IdentityType)COMUtilities.ReadIntFromKey(key, null, "IdentityType");
     ServerType     = (ServerType)COMUtilities.ReadIntFromKey(key, null, "ServerType");
     InstancingType = (InstancingType)COMUtilities.ReadIntFromKey(key, null, "InstancingType");
     Identity       = COMUtilities.ReadStringFromKey(key, null, "Identity");
     ServiceName    = COMUtilities.ReadStringFromKey(key, null, "ServiceName");
     ExePath        = COMUtilities.ReadStringFromKey(key, null, "ExePath");
     Permissions    = string.Empty;
     byte[] permissions = key.GetValue("Permissions", new byte[0]) as byte[];
     Permissions = COMSecurity.GetStringSDForSD(permissions);
 }
コード例 #5
0
        internal COMCLSIDElevationEntry(RegistryKey key, RegistryKey vso_key, bool auto_approval)
        {
            Enabled       = COMUtilities.ReadIntFromKey(key, null, "Enabled") != 0;
            IconReference = COMUtilities.ReadStringFromKey(key, null, "IconReference");
            HashSet <Guid> vsos = new HashSet <Guid>();

            if (vso_key != null)
            {
                foreach (string value in vso_key.GetValueNames())
                {
                    if (COMUtilities.IsValidGUID(value))
                    {
                        vsos.Add(new Guid(value));
                    }
                }
            }
            AutoApproval         = auto_approval;
            VirtualServerObjects = new List <Guid>(vsos).AsReadOnly();
        }
コード例 #6
0
 internal COMAppIDServiceEntry(RegistryKey key,
                               ServiceController service)
 {
     DisplayName = service.DisplayName;
     Name        = service.ServiceName;
     ServiceType = service.ServiceType;
     ServiceDll  = String.Empty;
     ImagePath   = String.Empty;
     UserName    = String.Empty;
     if (key != null)
     {
         UserName   = COMUtilities.ReadStringFromKey(key, null, "ObjectName");
         ImagePath  = COMUtilities.ReadStringFromKey(key, null, "ImagePath");
         ServiceDll = COMUtilities.ReadStringFromKey(key, "Parameters", "ServiceDll");
         if (String.IsNullOrEmpty(ServiceDll))
         {
             ServiceDll = COMUtilities.ReadStringFromKey(key, null, "ServiceDll");
         }
         ProtectionLevel = (ServiceProtectionLevel)COMUtilities.ReadIntFromKey(key, null, "LaunchProtected");
     }
 }
コード例 #7
0
        private void LoadFromKey(RegistryKey key)
        {
            HashSet <Guid> categories = new HashSet <Guid>();
            object         name       = key.GetValue(null);

            Name = null;
            if (name != null)
            {
                string s = name.ToString().Trim();

                if (s.Length > 0)
                {
                    Name = name.ToString();
                }
            }

            bool fake_name = false;

            if (Name == null)
            {
                fake_name = true;
                Name      = Clsid.FormatGuidDefault();
            }

            Dictionary <COMServerType, COMCLSIDServerEntry> servers = new Dictionary <COMServerType, COMCLSIDServerEntry>();
            COMCLSIDServerEntry inproc_server = ReadServerKey(servers, key, COMServerType.InProcServer32);

            ReadServerKey(servers, key, COMServerType.LocalServer32);
            ReadServerKey(servers, key, COMServerType.InProcHandler32);
            Servers = new ReadOnlyDictionary <COMServerType, COMCLSIDServerEntry>(servers);

            if (fake_name && inproc_server != null && inproc_server.HasDotNet)
            {
                Name = String.Format("{0}, {1}", inproc_server.DotNet.ClassName, inproc_server.DotNet.AssemblyName);
            }

            AppID = COMUtilities.ReadGuidFromKey(key, null, "AppID");
            if (AppID == Guid.Empty)
            {
                AppID = COMUtilities.ReadGuidFromKey(Registry.ClassesRoot,
                                                     String.Format(@"AppID\{0}", Path.GetFileName(DefaultServer)), "AppID");
            }

            if (AppID != Guid.Empty && !servers.ContainsKey(COMServerType.LocalServer32))
            {
                servers.Add(COMServerType.LocalServer32, new COMCLSIDServerEntry(COMServerType.LocalServer32, "<APPID HOSTED>"));
            }

            TypeLib = COMUtilities.ReadGuidFromKey(key, "TypeLib", null);
            if (key.HasSubkey("Control"))
            {
                categories.Add(ControlCategory);
            }

            if (key.HasSubkey("Insertable"))
            {
                categories.Add(InsertableCategory);
            }

            if (key.HasSubkey("DocObject"))
            {
                categories.Add(DocumentCategory);
            }

            using (RegistryKey catkey = key.OpenSubKey("Implemented Categories"))
            {
                if (catkey != null)
                {
                    string[] subKeys = catkey.GetSubKeyNames();
                    foreach (string s in subKeys)
                    {
                        Guid g;

                        if (Guid.TryParse(s, out g))
                        {
                            categories.Add(g);
                        }
                    }
                }
            }

            Categories = categories.ToList().AsReadOnly();
            TreatAs    = COMUtilities.ReadGuidFromKey(key, "TreatAs", null);

            using (RegistryKey elev_key = key.OpenSubKey("Elevation"),
                   vso_key = key.OpenSubKey("VirtualServerObjects"))
            {
                if (elev_key != null)
                {
                    using (var base_key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
                                                                  Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Default))
                    {
                        int auto_approval = COMUtilities.ReadIntFromKey(base_key,
                                                                        @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\UAC\COMAutoApprovalList", Clsid.ToString("B"));
                        Elevation = new COMCLSIDElevationEntry(elev_key, vso_key, auto_approval != 0);
                    }
                }
            }

            ActivatableFromApp = _app_activatable.Contains(Clsid);
        }