Error reading registry key

hello, i have this code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <windows.h>


using namespace std;


int main() {

    HKEY key ;
    if(RegOpenKey(HKEY_CURRENT_USER,TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"), &key )!=ERROR_SUCCESS){
        cout<<"Error 3x01\n";
    }else{
        int SIZE = 255;
     char value[SIZE];
    DWORD value_length = SIZE;
    RegQueryValueEx(key, "path", NULL, REG_SZ, (LPBYTE)&value, &value_length);
    cout << "path =  " << value << endl;
    }

}


i'm trying to read a registry key's value but codeblocks gives to me those errors:
|17|error: invalid conversion from 'int' to 'LPDWORD {aka long unsigned int*}' [-fpermissive]|
and
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\winreg.h|97|error: initializing argument 4 of 'LONG RegQueryValueExA(HKEY, LPCSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD)' [-fpermissive]|

Why? i'm inspired by this site http://www.dreamincode.net/forums/topic/171917-how-to-setread-registry-key-in-c/
but he doesn't declare the variable SIZE and i've done it by myself

Where is the error? thanks!!!
The problem is the fourth parameter REG_SZ. You need to provide a pointer to a DWORD (LPDWORD) in order to receive the type.

After receiving the type you may check whether it is the desired REG_SZ type.
THANKS!!! I'M LOOKING FOR A NICE ANSWER FROM 2 WEEKS!!
added:
 
DWORD dwType = REG_SZ;

now it works!
Topic archived. No new replies allowed.