本文整理汇总了C#中RegistryValueKind.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryValueKind.Equals方法的具体用法?C# RegistryValueKind.Equals怎么用?C# RegistryValueKind.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegistryValueKind
的用法示例。
在下文中一共展示了RegistryValueKind.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegistryWriter
//Write Registry Value
public bool RegistryWriter(string subKey, string keyName,string keyValue, RegistryValueKind valueType)
{
try
{
RegistryPermission regeditPermission = new RegistryPermission(RegistryPermissionAccess.AllAccess,System.IO.Path.Combine(Registry.CurrentUser.ToString(),System.IO.Path.Combine(ProcestaVariables.Variables.REGISTRY_PATH,subKey)));
regeditPermission.Demand();
RegistryKey regeditWrite=Registry.CurrentUser;
//regeditWrite.SetAccessControl(regeditUserRuls);
regeditWrite = regeditWrite.OpenSubKey(System.IO.Path.Combine(ProcestaVariables.Variables.REGISTRY_PATH, subKey), true);
if(regeditWrite!=null)
{
if(valueType.Equals(RegistryValueKind.Binary))
{
regeditWrite.SetValue(keyName,RegeditNecessaryFunction.ToByteArray(keyValue),RegistryValueKind.Binary);
regeditWrite.Close();
return true;
}
else if(valueType.Equals(RegistryValueKind.DWord))
{
regeditWrite.SetValue(keyName,Convert.ToInt32(keyValue),RegistryValueKind.DWord);
regeditWrite.Close();
return true;
}
else if( valueType.Equals(RegistryValueKind.ExpandString))
{
regeditWrite.SetValue(keyName,keyValue,RegistryValueKind.ExpandString);
regeditWrite.Close();
return true;
}
else if(valueType.Equals(RegistryValueKind.MultiString))
{
regeditWrite.SetValue(keyName,RegeditNecessaryFunction.ToStringArray(keyValue),RegistryValueKind.MultiString);
regeditWrite.Close();
return true;
}
else if(valueType.Equals(RegistryValueKind.QWord))
{
regeditWrite.SetValue(keyName,Convert.ToInt32(keyValue),RegistryValueKind.QWord);
regeditWrite.Close();
return true;
}
else
{
regeditWrite.SetValue(keyName,keyValue,RegistryValueKind.String);
regeditWrite.Close();
return true;
}
}
else
{
RegistryKey regKeyCrator=Registry.CurrentUser;
regKeyCrator = regKeyCrator.CreateSubKey(System.IO.Path.Combine(ProcestaVariables.Variables.REGISTRY_PATH, subKey), RegistryKeyPermissionCheck.Default);
regKeyCrator.Close();
RegistryWriter(subKey,keyName,keyValue,valueType);
return true;
}
}
catch (Exception e)
{
MessageBox.Show(ProcestaVariables.Variables.ERROR_MESSAGES[0,3] + Environment.NewLine + e, ProcestaVariables.Variables.ERROR_MESSAGES[0,0], MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false;
}
}