• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Permissions.RegistryPermission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Security.Permissions.RegistryPermission的典型用法代码示例。如果您正苦于以下问题:C# RegistryPermission类的具体用法?C# RegistryPermission怎么用?C# RegistryPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RegistryPermission类属于System.Security.Permissions命名空间,在下文中一共展示了RegistryPermission类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: HavePermissionsOnKey

 public static bool HavePermissionsOnKey(this RegistryPermission reg, RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return true;
     }
     catch (SecurityException)
     {
         return false;
     }
 }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:13,代码来源:RegistryExtensions.cs


示例17: HavePermissionsOnKey

 protected bool HavePermissionsOnKey(RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return true;
     }
     catch (SecurityException)
     {
         return false;
     }
 }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:13,代码来源:RegistryContextMenuItem.cs


示例18: ContentType

        /// <summary>
        /// Content Type
        /// </summary>
        /// <param name="filepath">File Path</param>
        /// <returns>Content Type</returns>
        public static string ContentType(string filepath)
        {
            if (string.IsNullOrWhiteSpace(filepath))
            {
                throw new ArgumentException("filepath");
            }
            else
            {
                var fi = new FileInfo(filepath);
                var dotExt = fi.Extension.ToUpperInvariant();

                if (string.IsNullOrWhiteSpace(dotExt))
                {
                    throw new InvalidOperationException(string.Format("Unknown extension: {0}", dotExt));
                }
                else if (types.ContainsKey(dotExt))
                {
                    return types[dotExt];
                }
                else
                {
                    var regPerm = new RegistryPermission(RegistryPermissionAccess.Read, "\\\\HKEY_CLASSES_ROOT");
                    using (var classesRoot = Registry.ClassesRoot)
                    {
                        using (var typeKey = classesRoot.OpenSubKey("MIME\\Database\\Content Type"))
                        {
                            foreach (var keyname in typeKey.GetSubKeyNames())
                            {
                                using (var curKey = classesRoot.OpenSubKey("MIME\\Database\\Content Type\\" + keyname))
                                {
                                    var extension = curKey.GetValue("Extension");
                                    if (null != extension && extension.ToString().ToUpperInvariant() == dotExt)
                                    {
                                        return keyname;
                                    }
                                }
                            }
                        }
                    }

                    return null;
                }
            }
        }
开发者ID:dineshkummarc,项目名称:A-Trak,代码行数:49,代码来源:ContentTypes.cs


示例19: _UnsafeGetAssertPermSet

        internal static PermissionSet _UnsafeGetAssertPermSet() {
            // SEC_NOTE: All callers should already be guarded by EventLogPermission demand.
            PermissionSet permissionSet = new PermissionSet(PermissionState.None);

            // We need RegistryPermission 
            RegistryPermission registryPermission = new RegistryPermission(PermissionState.Unrestricted);
            permissionSet.AddPermission(registryPermission);

            // It is not enough to just assert RegistryPermission, for some regkeys
            // we need to assert EnvironmentPermission too
            EnvironmentPermission environmentPermission = new EnvironmentPermission(PermissionState.Unrestricted);
            permissionSet.AddPermission(environmentPermission);

            // For remote machine registry access UnmanagdCodePermission is required.
            SecurityPermission securityPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
            permissionSet.AddPermission(securityPermission);

            return permissionSet;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:19,代码来源:EventLog.cs


示例20: RunSecurityDemands

        public static bool RunSecurityDemands()
        {
            FileIOPermission fPer = new FileIOPermission(PermissionState.None);
            fPer.AllLocalFiles = FileIOPermissionAccess.AllAccess;
            fPer.AllFiles = FileIOPermissionAccess.AllAccess;
            try
            {
                fPer.Demand();
            }
            catch (SecurityException s)
            {
                Common.DebugHelper.WriteLine("File IO Permission Error: {0}", s.Message);
                return false;
            }

            System.Security.Permissions.FileDialogPermission fdPer = new FileDialogPermission(FileDialogPermissionAccess.None);
            fdPer.Access = FileDialogPermissionAccess.OpenSave;
            try
            {
                fdPer.Demand();
            }
            catch (System.Security.SecurityException s)
            {
                Common.DebugHelper.WriteLine("File Dialog Persmission Error: {0}", s.Message);
                return false;
            }

            System.Security.Permissions.RegistryPermission rPer = new RegistryPermission(PermissionState.None);
            rPer.SetPathList(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE");
            try
            {
                fPer.Demand();
            }
            catch (System.Security.SecurityException s)
            {
                Common.DebugHelper.WriteLine("Registry Access Permission Error: {0}", s.Message);
                return false;
            }

            return true;
        }
开发者ID:JoeGilkey,项目名称:RadioLog,代码行数:41,代码来源:App.xaml.cs



注:本文中的System.Security.Permissions.RegistryPermission类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Permissions.SecurityPermission类代码示例发布时间:2022-05-26
下一篇:
C# Permissions.PrincipalPermission类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap