Error with RegOpenKeyEx ()

I use 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); 

Return Qt:

 `KEY_WOW64_64KEY' undeclared (first use in this function) 

I added "#include <windows.h>" , but it still does not work.

I found this entry Error with RegOpenKeyEx , this is the same problem as me, and the answer looks good. But I do not use Windows XP, I use 7 (64 bit). So I tried putting in targetver.h:

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

And it still does not work ... :(

What can I do?: (

Thanks:)

(sorry for my bad english)

+4
source share
1 answer

You must define _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> 
+4
source

Source: https://habr.com/ru/post/1435469/


All Articles