将不同的注册表值类型转换为字符串? [英] Converting different registry value types to string?

查看:64
本文介绍了将不同的注册表值类型转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遍历注册表,获取键的值并将它们存储为字符串.我发现有很多不同的类型.其中一些类型导致我的文件流编写器失败.是否可以将以下所有内容转换为字符串形式.实际数据值并不重要,重要的是区分不同值的能力.

im traversing through the registry, taking the values of the keys and storing them as strings. I have discovered there are many different types. Some of these types are causing my filestream writer to fail. Is it possible to convert all of the below into a string form. The actual data value is not important, just the ability to differentiate between different values.

  • 双字
  • 扩展字符串
  • 二进制(这和 byte[] 一样吗?)
  • 多字符串

-

if (String.Compare(SubKey.GetValueKind(v[i]).ToString(), "String") == 0)
{
    String s = SubKey.GetValue(v[i]).ToString();

    RegistryKeyDataValue rkdv = new RegistryKeyDataValue(s); 
    rkdv.incrementNumberOfTimesUsed();
    rkdv.setTypeOfData("S");

    r.addDataValue(rkdv);
    r.setCurrentDataValue(s);

    String hash = "";
    h.setHashData(hash); 

    hash = h.HashString(s);
}

我稍后遇到问题,因为我想将值写入文件,并且需要将所有不同类型转换为字符串.

I'm having problems later on because i want to write the values to a file and i need to convert all different types to a string.

推荐答案

对于将注册表值作为字符串写入文件,已经有一个不错的标准.在 Regedit.exe 中,选择一个键后使用 File + Export 来查看它的样子.此知识库文章中提供了文档.

There already is a decent standard for writing registry values as strings to a file. In Regedit.exe, use File + Export after selecting a key to see what that looks like. Documentation is available in this KB article.

这篇关于将不同的注册表值类型转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆