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