错误与RegOpenKeyEx() [英] Error with RegOpenKeyEx()

查看:662
本文介绍了错误与RegOpenKeyEx()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用qt与mingw写一个程序,更改注册表,但当我调用:

  RegOpenKeyEx HKEY_LOCAL_MACHINE,
SOFTWARE\\Microsoft\\Windows NT\\\CurrentVersion\\DefaultProductKey,
0,
KEY_ALL_ACCESS | KEY_WOW64_64KEY,
& ;键);

Qt return:

 `KEY_WOW64_64KEY'undeclared(在此函数中第一次使用)

code>#include< windows.h>,但仍然无效。



发布 RegOpenKeyEx 的错误,这是我的问题,而且回答看起来不错。
但是我不使用windows xp我使用7(64位)。
所以我引用了targetver.h:

  #ifndef _WIN32_WINNT_WIN7 
#define _WIN32_WINNT_WIN7(0x0601 )
#endif / * _WIN32_WINNT_WIN7 * /

。:(



我能做什么?:(



感谢:)



(对不起我的英文版)

解决方案

您必须定义

$

$

$

$ <$ p $ <$>
(不是_WIN32_WINNT_WIN7) p> #ifndef _WIN32_WINNT
#define _WIN32_WINNT(0x0601)
#endif / * _WIN32_WINNT * /

#include< windows.h>


I'm using Qt with mingw to write a program that changes the registry, but when I call :

RegOpenKeyEx(HKEY_LOCAL_MACHINE,
             "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DefaultProductKey",
             0,
             KEY_ALL_ACCESS|KEY_WOW64_64KEY,
             &key);

Qt return :

`KEY_WOW64_64KEY' undeclared (first use in this function)

I had add "#include <windows.h>" but it still doesn't work.

I've find this post Error with RegOpenKeyEx, it's the same probleme than me, and the answer looks good. But i'm not using windows xp i'm using 7(64bits). So I trided to put in targetver.h :

#ifndef _WIN32_WINNT_WIN7
#define _WIN32_WINNT_WIN7 (0x0601)
#endif  /* _WIN32_WINNT_WIN7 */

And it's still doesn't work ... :(

What can i do ? :(

Thanks :)

(sorry for my bad english)

解决方案

You have to define the _WIN32_WINNT (not _WIN32_WINNT_WIN7) before including the windows.h header:

#ifndef _WIN32_WINNT
#define _WIN32_WINNT (0x0601)
#endif  /* _WIN32_WINNT */

#include <windows.h>

这篇关于错误与RegOpenKeyEx()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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