本文整理汇总了C#中Registry.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.GetValue方法的具体用法?C# Registry.GetValue怎么用?C# Registry.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry.GetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteToFile
protected static void WriteToFile(StreamWriter streamWriter,
Registry registry,
RegistryKeyType keyType,
string subKey)
{
try
{
string line = "";
try
{
line = "[" + ((RegistryNodeType)keyType);
if (!String.IsNullOrEmpty(subKey))
{
line += "\\" + subKey;
}
line += "]";
streamWriter.WriteLine(line);
if (!registry.Open(keyType, subKey))
{
line = "ERROR - COULD NOT OPEN";
streamWriter.WriteLine(line);
return;
}
}
catch (Exception exception)
{
line = "ERROR - " + exception.Message.ToUpper();
streamWriter.WriteLine(line);
return;
}
string[] valueNames = registry.GetValueNames();
if (valueNames == null)
{
line = "ERROR - COULD NOT GET VALUE NAMES";
streamWriter.WriteLine(line);
}
else
{
foreach (string valueName in valueNames)
{
if (String.IsNullOrEmpty(valueName))
{
line = "@=";
}
else
{
line = "\"" + valueName + "\"=";
}
object value = registry.GetValue(valueName);
if (value == null)
{
line += "NULL";
}
else
{
line += "\"" + value + "\"";
}
try
{
streamWriter.WriteLine(line);
}
catch (Exception exception)
{
line = "ERROR - " + exception.Message.ToUpper();
streamWriter.WriteLine(line);
}
}
}
streamWriter.WriteLine("");
string[] subKeyNames = registry.GetSubKeyNames();
if (subKeyNames == null)
{
line = "ERROR - COULD NOT GET SUBKEY NAMES";
streamWriter.WriteLine(line);
}
else
{
foreach (string subKeyName in subKeyNames)
{
string subKeyPath = "";
//.........这里部分代码省略.........