如何更新注册表中的文本 [英] How to update text in the registry

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

问题描述


我已在注册表中存储了一个值,并希望通过编写新的文本字符串来更新它。所以我想知道是否有人可以告诉我为什么以下不起作用:


 

HKEY Hkey;

Keyname = TEXT(" mrg");
Keyvalue = TEXT(" TestData \ 0");


if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,L" SOFTWARE \\Myprogram\\Settings",0,KEY_ALL_ACCESS,& Hkey)== ERROR_SUCCESS)
regerror = RegSetValueEx(Hkey,Keyname,0,REG_SZ,(LPBYTE)Keyvalue,_tcslen(Keyvalue)* sizeof(TCHAR));


regerror == ERROR_SUCCESS,但注册表中没有任何内容。


提前致谢。


解决方案

你在跑一个64位版本的Windows? 如果是,您的应用程序是32位还是64位代码,您是在查找64位注册表还是在Wow6432Node部分中查找32位代码? 请参阅

https://docs.microsoft.com/en-us/windows/desktop/sysinfo/32-bit-and-64-bit-application-data-in-the-registry


I have stored a value in the registry and want to update it by writing a new text string. So I wonder if someone could tell me why the following doesn't work:

HKEY Hkey;

Keyname = TEXT("mrg"); Keyvalue = TEXT("TestData\0"); if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Myprogram\\Settings", 0, KEY_ALL_ACCESS, &Hkey ) == ERROR_SUCCESS) regerror = RegSetValueEx(Hkey, Keyname, 0, REG_SZ, (LPBYTE)Keyvalue, _tcslen(Keyvalue) * sizeof(TCHAR));

regerror == ERROR_SUCCESS, but nothing shows up in the registry.

Thanks in advance.

解决方案

Are you running a 64 bit version of Windows?  If yes, is your application 32 bit or 64 bit code and are you looking in the 64 bit registry or in the Wow6432Node portion for 32 bit code?  See https://docs.microsoft.com/en-us/windows/desktop/sysinfo/32-bit-and-64-bit-application-data-in-the-registry


这篇关于如何更新注册表中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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