简体   繁体   English

WINAPI:Windows注册表功能失败

[英]WINAPI: Windows Registry functions fail

I have a trouble writing some keys into registry: 我在注册表中写入一些密钥很麻烦:

PHKEY key = NULL; HRESULT hResult = S_FALSE;
hResult = RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("AppID"), 0, KEY_CREATE_SUB_KEY, key);

and this fails with code 0x00000057 - The parameter is incorrect. 并且失败,代码为0x00000057 - The parameter is incorrect.

hResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("new_key_name"), 0, NULL,
    REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, key, NULL);

this fails with code 0x000003f2 - The configuration registry key is invalid. 这将失败,代码为0x000003f2 - The configuration registry key is invalid.

I have also tried some variations, but the result is always the same. 我也尝试了一些变体,但结果始终相同。 I was using this functions before and never had a problem. 我以前使用过此功能,但从未遇到过问题。 I'm totally confused. 我很困惑。

Can anyone help??? 谁能帮忙???

In the first example, the last parameter (HKEY *) returns the new key. 在第一个示例中,最后一个参数(HKEY *)返回新密钥。 You must provide the variable (HKEY, not PHKEY) where RegOpenKeyEx should store the value, and pass its address: 您必须在RegOpenKeyEx应该存储值的位置提供变量(HKEY,而不是PHKEY),并传递其地址:

HKEY key = 0;
hResult = RegOpenKeyEx(...., &key);

The second call may have the same problem. 第二个电话可能有相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM