當前位置: 首頁>>代碼示例>>C#>>正文


C# Permissions.RegistryPermission類代碼示例

本文整理匯總了C#中System.Security.Permissions.RegistryPermission的典型用法代碼示例。如果您正苦於以下問題:C# RegistryPermission類的具體用法?C# RegistryPermission怎麽用?C# RegistryPermission使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RegistryPermission類屬於System.Security.Permissions命名空間,在下文中一共展示了RegistryPermission類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetIsRegistryAvailable

 /// <summary>
 /// Checks to see if Registry access is available to the caller
 /// 
 /// </summary>
 /// 
 /// <returns/>
 public bool GetIsRegistryAvailable()
 {
   PermissionSet permissionSet = new PermissionSet(PermissionState.None);
   RegistryPermission registryPermission = new RegistryPermission(PermissionState.Unrestricted);
   permissionSet.AddPermission((IPermission) registryPermission);
   return permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
 }
開發者ID:kirillbeldyaga,項目名稱:web_browser,代碼行數:13,代碼來源:PermissionHelper.cs

示例2: RegistryReadr

 //Read Registry
 public string RegistryReadr(string subKey,string keyName)
 {
     try
     {
         RegistryPermission regeditPermission = new RegistryPermission(RegistryPermissionAccess.Read, System.IO.Path.Combine(Registry.CurrentUser.ToString(), System.IO.Path.Combine(ProcestaVariables.Variables.REGISTRY_PATH, subKey)));
         regeditPermission.Demand();
         RegistryKey regeditRead = Registry.CurrentUser;
         regeditRead = regeditRead.OpenSubKey(System.IO.Path.Combine(ProcestaVariables.Variables.REGISTRY_PATH, subKey));
         if (regeditRead != null)
         {
             if ((regeditRead.GetValue(keyName)).GetType().Equals(typeof(Int32)))
             {
                 return regeditRead.GetValue(keyName).ToString();
             }
             else
             {
                 return (string)regeditRead.GetValue(keyName);
             }
         }
         else
         {
             RegistryWriter(subKey,keyName,string.Empty,RegistryValueKind.String);
             RegistryReadr(subKey, keyName);
             return null;
         }
     }
     catch (Exception)
     {
         MessageBox.Show(ProcestaVariables.Variables.ERROR_MESSAGES[0,4], ProcestaVariables.Variables.ERROR_MESSAGES[0,0], MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
開發者ID:shuvo009,項目名稱:ProcestaPetunia,代碼行數:33,代碼來源:RegeditWriteRead.cs

示例3: DemandLocalMachineAccess

            /// <summary>
            /// Call this function before creating the RegistryUtils class in order to make sure that
            /// you (the caller) will have permissions to access the class.
            /// </summary>
            /// <param name="subKey">
            /// The sub key to demand permissions for.
            /// </param>
            public static void DemandLocalMachineAccess(string subKey)
            {
                // Create permission objects for the registry keys we're about to use.
                RegistryPermission readPermissions = new RegistryPermission(RegistryPermissionAccess.Read, @"HKEY_LOCAL_MACHINE\" + subKey);

                // Now force this function to throw a SecurityException if we don't already have these permissions.
                readPermissions.Demand();
            }
開發者ID:transformersprimeabcxyz,項目名稱:_TO-FIRST-stylecop,代碼行數:15,代碼來源:RegistryUtils.Permissions.cs

示例4: CheckSecurity

 private void CheckSecurity()
 {
     //check registry permissions
     RegistryPermission regPerm;
     regPerm = new RegistryPermission(RegistryPermissionAccess.Write, "HKEY_CLASSES_ROOT\\" + MenuName);
     regPerm.AddPathList(RegistryPermissionAccess.Write, "HKEY_CLASSES_ROOT\\" + Command);
     regPerm.Demand();
 }
開發者ID:KillerGoldFisch,項目名稱:GCharp,代碼行數:8,代碼來源:ContextMenueEntrys.cs

示例5: OpenOrCreateCompanyKey

 public static RegistryKey OpenOrCreateCompanyKey(this RegistryKey source)
 {
     RegistryPermission f = new RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\\SOFTWARE");
     RegistryKey keySoftware = source.OpenOrCreateKey("SOFTWARE");
     AssemblyCompanyAttribute companyAttribute = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute)).FirstOrDefault() as AssemblyCompanyAttribute;
     RegistryKey keyCompany = keySoftware.OpenOrCreateKey(companyAttribute.Company);
     return keyCompany;
 }
開發者ID:ChampsyGnom,項目名稱:GeoPat,代碼行數:8,代碼來源:RegistryExtension.cs

示例6: DemandCurrentUserAccess

            /// <summary>
            /// Call this function before creating the RegistryUtils class in order to make sure that
            /// you (the caller) will have permissions to access the class.
            /// </summary>
            /// <param name="subKey">
            /// The sub key to demand permissions for.
            /// </param>
            public static void DemandCurrentUserAccess(string subKey)
            {
                // Create permission objects for the registry keys we're about to use.
                RegistryPermission fullPermissions = new RegistryPermission(RegistryPermissionAccess.AllAccess, @"HKEY_CURRENT_USER\" + subKey);

                // Now force this function to throw a SecurityException if we don't already have these permissions.
                fullPermissions.Demand();
            }
開發者ID:transformersprimeabcxyz,項目名稱:_TO-FIRST-stylecop,代碼行數:15,代碼來源:RegistryUtils.Permissions.cs

示例7: WebTransform

        /// <summary>
        /// Creates a new WebTransform.
        /// </summary>
        public WebTransform()
        {
            //[IsolatedStorageFilePermissionAttribute(SecurityAction.Demand, Unrestricted=true)]
            FileIOPermission filePerm = new FileIOPermission(PermissionState.None);
            RegistryPermission regPerm = new RegistryPermission(PermissionState.None);

            filePerm.Demand();
            regPerm.Demand();
        }
開發者ID:molekilla,項目名稱:Ecyware_GreenBlue_Inspector,代碼行數:12,代碼來源:WebTransform.cs

示例8: PermissionStateUnrestricted

		public void PermissionStateUnrestricted ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.Unrestricted);
			Assert.IsNotNull (ep, "RegistryPermission(PermissionState.Unrestricted)");
			Assert.IsTrue (ep.IsUnrestricted (), "IsUnrestricted");
			RegistryPermission copy = (RegistryPermission)ep.Copy ();
			Assert.AreEqual (ep.IsUnrestricted (), copy.IsUnrestricted (), "Copy.IsUnrestricted");
			SecurityElement se = ep.ToXml ();
			Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "ToXml-Unrestricted");
		}
開發者ID:RobertZenz,項目名稱:mono,代碼行數:10,代碼來源:RegistryPermissionTest.cs

示例9: PermissionStateUnrestricted

		public void PermissionStateUnrestricted ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.Unrestricted);
			AssertNotNull ("RegistryPermission(PermissionState.Unrestricted)", ep);
			Assert ("IsUnrestricted", ep.IsUnrestricted ());
			RegistryPermission copy = (RegistryPermission)ep.Copy ();
			AssertEquals ("Copy.IsUnrestricted", ep.IsUnrestricted (), copy.IsUnrestricted ());
			SecurityElement se = ep.ToXml ();
			AssertEquals ("ToXml-Unrestricted", "true", se.Attribute ("Unrestricted"));
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:10,代碼來源:RegistryPermissionTest.cs

示例10: GravaValor

        /// <summary>
        /// Grava um par chave valor no registro do windows
        /// </summary>
        /// <param name="chave">chave usada para identificar o objeto</param>
        /// <param name="valor">valor a ser guardado</param>
        public static void GravaValor(string chave, string valor)
        {
            var perm1 = new RegistryPermission(RegistryPermissionAccess.Write, Key);


            if (perm1.CanWriteKey(Key))
            {
                GravaValor(Key, chave, valor);
            }
        }
開發者ID:RodrigoDotNet,項目名稱:gerador-de-camadas,代碼行數:15,代碼來源:RegistroWindows.cs

示例11: Demand

            /// <summary>
            /// Call this function before creating the RegistryUtils class in order to make sure that
            /// you (the caller) will have permissions to access the class.
            /// </summary>
            public static void Demand()
            {
                // Create permission objects for the registry keys we're about to use.
                string fullRegistryPath = @"HKEY_CURRENT_USER\Software\Microsoft\" + ApplicationAcronym;
                RegistryPermission fullPermissions =
                    new RegistryPermission(RegistryPermissionAccess.AllAccess, fullRegistryPath);

                // Now force this function to throw a SecurityException if we don't already have these permissions.
                fullPermissions.Demand();
            }
開發者ID:katerina-marchenkova,項目名稱:my,代碼行數:14,代碼來源:RegistryUtils.Permissions.cs

示例12: _UnsafeGetAssertPermSet

 internal static PermissionSet _UnsafeGetAssertPermSet()
 {
     PermissionSet set = new PermissionSet(PermissionState.None);
     RegistryPermission perm = new RegistryPermission(PermissionState.Unrestricted);
     set.AddPermission(perm);
     EnvironmentPermission permission2 = new EnvironmentPermission(PermissionState.Unrestricted);
     set.AddPermission(permission2);
     SecurityPermission permission3 = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     set.AddPermission(permission3);
     return set;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:11,代碼來源:EventLog.cs

示例13: PermissionStateNone

		public void PermissionStateNone ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			AssertNotNull ("RegistryPermission(PermissionState.None)", ep);
			Assert ("IsUnrestricted", !ep.IsUnrestricted ());
			RegistryPermission copy = (RegistryPermission)ep.Copy ();
			AssertEquals ("Copy.IsUnrestricted", ep.IsUnrestricted (), copy.IsUnrestricted ());
			SecurityElement se = ep.ToXml ();
			Assert ("ToXml-class", se.Attribute ("class").StartsWith (className));
			AssertEquals ("ToXml-version", "1", se.Attribute ("version"));
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:11,代碼來源:RegistryPermissionTest.cs

示例14: PermissionStateNone

		public void PermissionStateNone ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			Assert.IsNotNull (ep, "RegistryPermission(PermissionState.None)");
			Assert.IsTrue (!ep.IsUnrestricted (), "IsUnrestricted");
			RegistryPermission copy = (RegistryPermission)ep.Copy ();
			Assert.AreEqual (ep.IsUnrestricted (), copy.IsUnrestricted (), "Copy.IsUnrestricted");
			SecurityElement se = ep.ToXml ();
			Assert.IsTrue (se.Attribute ("class").StartsWith (className), "ToXml-class");
			Assert.AreEqual ("1", se.Attribute ("version"), "ToXml-version");
		}
開發者ID:RobertZenz,項目名稱:mono,代碼行數:11,代碼來源:RegistryPermissionTest.cs

示例15: CanReadKey

 public static bool CanReadKey(this RegistryPermission reg, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(RegistryPermissionAccess.Read, key);
         r.Demand();
         return true;
     }
     catch (SecurityException)
     {
         return false;
     }
 }
開發者ID:WELL-E,項目名稱:Hurricane,代碼行數:13,代碼來源:RegistryExtensions.cs


注:本文中的System.Security.Permissions.RegistryPermission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。