本文整理汇总了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();
}
示例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;
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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);
}
}
示例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