当前位置: 首页>>代码示例>>C#>>正文


C# RegistryPermission.AddPathList方法代码示例

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


在下文中一共展示了RegistryPermission.AddPathList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: CreatePermission

		// Methods
		public override IPermission CreatePermission ()
		{
			RegistryPermission perm = null;
			if (this.Unrestricted)
				perm = new RegistryPermission (PermissionState.Unrestricted);
			else {
				perm = new RegistryPermission (PermissionState.None);
				if (create != null)
					perm.AddPathList (RegistryPermissionAccess.Create, create);
				if (read != null)
					perm.AddPathList (RegistryPermissionAccess.Read, read);
				if (write != null)
					perm.AddPathList (RegistryPermissionAccess.Write, write);
			}
			return perm;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:17,代码来源:RegistryPermissionAttribute.cs

示例3: GetPathList

		public void GetPathList ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
#if NET_2_0
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Create-Empty");
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read-Empty");
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write-Empty");
#else
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Create-Empty");
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read-Empty");
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write-Empty");
#endif
			ep.AddPathList (RegistryPermissionAccess.Create, keyLocalMachine);
			ep.AddPathList (RegistryPermissionAccess.Create, keyCurrentUser);
			Assert.AreEqual (keyLocalMachine + ";" + keyCurrentUser, ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Read");

			ep.AddPathList (RegistryPermissionAccess.Read, keyLocalMachine);
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read");

			ep.AddPathList (RegistryPermissionAccess.Write, keyCurrentUser);
			Assert.AreEqual (keyCurrentUser, ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write");
		}
开发者ID:RobertZenz,项目名称:mono,代码行数:22,代码来源:RegistryPermissionTest.cs

示例4: GetPathListNoAccess

		public void GetPathListNoAccess ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			ep.AddPathList (RegistryPermissionAccess.Read, keyCurrentUser);
			ep.AddPathList (RegistryPermissionAccess.Write, keyLocalMachine);
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.NoAccess), "GetPathList-NoAccess");
		}
开发者ID:RobertZenz,项目名称:mono,代码行数:7,代码来源:RegistryPermissionTest.cs

示例5: AddPathList_Subset

		public void AddPathList_Subset ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			ep.AddPathList (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			ep.AddPathList (RegistryPermissionAccess.AllAccess, keyLocalMachineSubset);
			SecurityElement se = ep.ToXml ();
			Assert.AreEqual (keyLocalMachineSubset, se.Attribute ("Create"), "AddPathList-ToXml-Create");
			Assert.AreEqual (keyLocalMachineSubset, se.Attribute ("Read"), "AddPathList-ToXml-Read");
			Assert.AreEqual (keyLocalMachineSubset, se.Attribute ("Write"), "AddPathList-ToXml-Write");

			ep = new RegistryPermission (PermissionState.None);
			ep.AddPathList (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			ep.AddPathList (RegistryPermissionAccess.Create, keyLocalMachineSubset);
			ep.AddPathList (RegistryPermissionAccess.Read, keyCurrentUser);
			se = ep.ToXml ();
			Assert.AreEqual (keyLocalMachineSubset, se.Attribute ("Create"), "AddPathList-ToXml-Create");
			Assert.AreEqual (keyLocalMachine + ";" + keyCurrentUser, se.Attribute ("Read"), "AddPathList-ToXml-Read");
			Assert.AreEqual (keyLocalMachine, se.Attribute ("Write"), "AddPathList-ToXml-Write");
		}
开发者ID:RobertZenz,项目名称:mono,代码行数:19,代码来源:RegistryPermissionTest.cs

示例6: AddPathList

		public void AddPathList ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			ep.AddPathList (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			// LAMESPEC NoAccess do not remove the keyLocalMachine from AllAccess
			ep.AddPathList (RegistryPermissionAccess.NoAccess, keyLocalMachine);
			ep.AddPathList (RegistryPermissionAccess.Read, keyCurrentUser);
			ep.AddPathList (RegistryPermissionAccess.Write, keyCurrentUser);
			SecurityElement se = ep.ToXml ();
			// Note: Debugger can mess results (try to run without stepping)
			Assert.AreEqual (@"HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Novell iFolder\1.00.000", se.Attribute ("Create"), "AddPathList-ToXml-Create");
			Assert.AreEqual (@"HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Novell iFolder\1.00.000;HKEY_CURRENT_USER\Software\Novell iFolder\spouliot\Home", se.Attribute ("Read"), "AddPathList-ToXml-Read");
			Assert.AreEqual (@"HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Novell iFolder\1.00.000;HKEY_CURRENT_USER\Software\Novell iFolder\spouliot\Home", se.Attribute ("Write"), "AddPathList-ToXml-Write");
		}
开发者ID:RobertZenz,项目名称:mono,代码行数:14,代码来源:RegistryPermissionTest.cs

示例7: SetAppKey

 internal void SetAppKey(string AppName)
 {
     try
     {
         //SubKeys.SawyerHklmName = @topLevel;
         //SubKeys.SawyerHkcuName = @topLevel;
         SawyerHklmName = @topLevel;
         SawyerHkcuName = @topLevel;
         AppHklmName = @topLevel + @"\" + AppName;
         AppHklmName = @topLevel + @"\" + AppName;
         string
             hklm = @"HKEY_LOCAL_MACHINE\",
             hkcu = @"HKEY_CURRENT_USER\";
         regPerm = new RegistryPermission(PermissionState.Unrestricted);
         regPerm.AddPathList(RegistryPermissionAccess.AllAccess,
             hklm + topLevel + ";" +
             hklm + topLevel + @"\" + AppName + ";" +
             hkcu + topLevel + ";" +
             hkcu + topLevel + @"\" + AppName);
         regPerm.Demand();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
开发者ID:SawyerNursery,项目名称:PottingInformation,代码行数:26,代码来源:Global4k.cs

示例8: SaveRegistySetting

        private void SaveRegistySetting()
        {
            RegistryPermission regPermis = new RegistryPermission(
                RegistryPermissionAccess.Write | RegistryPermissionAccess.Create, kProgramSubKey);

            RegistryKey regKey = Registry.CurrentUser.CreateSubKey(kProgramSubKey);
            if (regKey != null)
            {
                regPermis.AddPathList(
                    RegistryPermissionAccess.Write | RegistryPermissionAccess.Create,
                    kProgramSubKey + "\\" + kKeyDestinationDir);

                regPermis.AddPathList(
                    RegistryPermissionAccess.Write | RegistryPermissionAccess.Create,
                    kProgramSubKey + "\\" + kKeySourceDir);

                RegistryKey regSubKey = regKey.CreateSubKey(kKeyDestinationDir);
                if (regSubKey != null)
                {
                    regKey.SetValue(kKeyDestinationDir, textBoxDestinationDir.Text, RegistryValueKind.String);
                }

                RegistryKey regSubKeyLastTab = regKey.CreateSubKey(kKeyLastTab);
                if (regKey != null)
                {
                    regKey.SetValue(kKeyLastTab, String.Format("{0}",tabOfficeOptions.SelectedIndex), RegistryValueKind.String);
                }

                RegistryKey regSubKeySourceDir = regKey.CreateSubKey(kKeySourceDir);
                if (regSubKeySourceDir != null)
                {
                    regKey.SetValue(kKeySourceDir, textBoxFileFolderToClean.Text, RegistryValueKind.String);
                }

                RegistryKey regFolderOption = regKey.CreateSubKey(kKeyFolderOption);
                if (regFolderOption != null)
                {
                    regKey.SetValue(kKeyFolderOption, radioButtonSelectFolder.Checked, RegistryValueKind.String);
                }

                RegistryKey regDetectionOption = regKey.CreateSubKey(kKeyDetectionOption);
                if (regDetectionOption != null)
                {
                    regKey.SetValue(kKeyDetectionOption, radioButtonDetection.Checked, RegistryValueKind.String);
                }

                RegistryKey regOfficeAutomationOption = regKey.CreateSubKey(kKeyOfficeAutomationOption);
                if (regOfficeAutomationOption != null)
                {
                    regKey.SetValue(kKeyOfficeAutomationOption, checkBoxOfficeAutomation.Checked, RegistryValueKind.String);
                }

                RegistryKey regFCSLibraryOption = regKey.CreateSubKey(kKeyFCSLibraryOption);
                if (regFCSLibraryOption != null)
                {
                    regKey.SetValue(kKeyFCSLibraryOption, checkBoxFCSLibraryOption.Checked, RegistryValueKind.String);
                }

                RegistryKey regPowerPointOptions = regKey.CreateSubKey(kKeyPowerPointOptions);
                if (regPowerPointOptions != null)
                {
                    FillBinaryArray(m_powerPointByteArray, m_OFELib.PowerPointOptionsMax, m_checkBoxPowerPointCleaningOptionsArray);

                    regKey.SetValue(kKeyPowerPointOptions, m_powerPointByteArray, RegistryValueKind.Binary);
                }

                RegistryKey regWordOptions = regKey.CreateSubKey(kKeyWordOptions);
                if (regWordOptions != null)
                {
                    FillBinaryArray(m_wordByteArray, m_OFELib.WordOptionsMax, m_checkBoxWordCleaningOptionsArray);

                    regKey.SetValue(kKeyWordOptions, m_wordByteArray, RegistryValueKind.Binary);
                }
              
                RegistryKey regExcelOptions = regKey.CreateSubKey(kKeyExcelOptions);
                if (regExcelOptions != null)
                {
                    FillBinaryArray(m_excelByteArray, m_OFELib.ExcelOptionsMax, m_checkBoxExcelCleaningOptionsArray);

                    regKey.SetValue(kKeyExcelOptions, m_excelByteArray, RegistryValueKind.Binary);
                }
            }
        }//end of  SaveRegistySetting
开发者ID:killbug2004,项目名称:WSProf,代码行数:83,代码来源:MainForm.cs


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