當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。