如何从注册表项中删除注册表值和键 [英] How to remove registry value and key from registry entry
问题描述
我已经使用 RegSetValueExA
在注册表项中设置了键和值,并且它已创建.但是现在我想从注册表项中删除该键和值,为此我使用 RegDeleteKey
但它给出了错误 2,即系统找不到指定的文件.",你能告诉我如何我能解决这个问题吗.
I already setting key and value in the registry entry by using RegSetValueExA
, and it's created . But Now I want to delete that key and value from registry entry and for that I am using RegDeleteKey
but its giving error 2 which is "The system cannot find the file specified.", can you tell me how can I solve this.
推荐答案
你能显示任何代码吗?它不能帮助这里的任何人缩小您的问题.
Can you show any codes at all? It doesn't help anyone here narrow down your problem.
不过,如果我猜测一下,您在 RegOpenKeyEx 或 RegDeleteKey 中指定 LPCTSTR lpSubKey 的方式有问题.
If I would take a guess though, there's something wrong with the way you have specified LPCTSTR lpSubKey in either RegOpenKeyEx or RegDeleteKey.
示例:
如果您创建了一个密钥:
If you created a key:
HKEY_LOCAL_MACHINE\Software\Test
为了删除它,你需要这样的东西:
In order to delete it, you would need something like this:
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software", 0, KEY_ALL_ACCESS, &RegHandle)
RegDeleteKey(RegHandle, test)
或
RegOpenKeyEx(HKEY_LOCAL_MACHINE, someNullValue, 0, KEY_ALL_ACCESS, &RegHandle)
RegDeleteKey(RegHandle, L"Software\\test")
请务必在 MSDN 上再次检查这些功能.
Make sure you check out the functions again at MSDN.
这篇关于如何从注册表项中删除注册表值和键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!