Why does RegOpenKeyEx return "0" value?


I use CodeBlocks version 20.03 (x86) as IDE.

Here are my codes:

#include "iostream"
#include "windows.h"
using namespace std;

int main()
    HKEY hkRegedit;
    long longHataKodu;

    longHataKodu = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Chkdsk", 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hkRegedit);

    cout << longHataKodu;


    return 0;

But the problem is even I run my program without administrator privileges, my program returns 0.

Here is the screenshot of my program:

enter image description here

How is that possible even I have written HKEY_LOCAL_MACHINE and KEY_ALL_ACCESS?

As far as I know, value 0 means ERROR_SUCCESS.


Registry virtualization is a compatibility shim for old applications that redirects writes to HKEY_USERS\<User SID>_Classes\VirtualStore instead of causing access denied errors.

To turn it off, add a manifest to your application with a requestedExecutionLevel node to mark yourself Vista/UAC compatible.

Answered By – Anders

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published