设置注册表项 hex7 [英] set registry key hex7

查看:108
本文介绍了设置注册表项 hex7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找用 c# 设置注册表项的函数.

i ve been searching for a function to set a registry key with c#.

显然有方法 Registry.SetValue(KEY, valueName, value, registryValueKind)

Obvously there is the method Registry.SetValue(KEY, valueName, value, registryValueKind)

[... 其中 valueName 是编辑值的名称,KEY 是主键名,registryValueKind 是要进行更改的类型]

[... whereby valueName is the name of the edited value, KEY is the main key name and registryValueKind is the type of change to be made]

如果你仔细看看 registryValueKind-Enum 有 8 种类型:

If you have a closer look at registryValueKind-Enum there are 8 types:

  • DWord、String、ExpandString、Binary、MultiString、QWord、Unknown 和没有.

Msdn 文章描述了不同的数据类型:

In a Msdn-Article the different data-types are described:

  • REG_SZ、REG_MULTI_SZ、REG_DWORD、REG_QWORD、REG_BINARY、REG_EXPAND_SZ、REG_HEX.

所以我想知道如何在 Registry.SetValue() 的帮助下存储十六进制 (7) 值 [因此是 REG_HEX 值].

So i wonder how to store a hex(7)-value [therefore a REG_HEX-value] with the help of Registry.SetValue().

我还想知道如何保存像 hex(7):56,00,45,00,4e,00,30,00,00,00,4c,00,4f,00,4f,00,50 这样的值,00,42,\00,41,00,43,00,4b,00,00,00,00,00 除了是由\"分隔的十六进制(7)类型之外.

Further i wonder how to save a value like hex(7):56,00,45,00,4e,00,30,00,00,00,4c,00,4f,00,4f,00,50,00,42,\ 00,41,00,43,00,4b,00,00,00,00,00 which is, in addition to being of type hex(7) seperated by a "\".

提前致谢!

推荐答案

没有十六进制值"这样的东西,十六进制只是二进制值的文本表示.

There is no such thing as "hexadecimal value", hexadecimal is just a textual representation of a binary value.

你想要的是:

Registry.SetValue(
    "HKEY_CURRENT_USER\\MyKeyName", 
    "MyValue", 
    new byte[] { 0x56, 0x00, 0x45, 0x00, 0x4e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x42, 0x00, 0x41, 0x00, 0x43, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00 }, 
    RegistryValueKind.Binary);

这篇关于设置注册表项 hex7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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