Hi,
I am trying to retrieve a specific key(i.e. I know the key name) from registry. Firstly I want to see if I can open the key successfully, but I am stuck at compiling.
----1st attempt----
1 2 3 4 5 6
|
#include<winreg.h>
HKEY key;
if (RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("Software\\foo\\"), &key) != ERROR_SUCCESS)
textbox->Text = L"FAIL";
else
textbox->Text = L"YEAH";
|
This piece of code gives error:
1 2
|
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(19787): error C3861: '__readfsdword': identifier not found
1>d:\foo\foo.h(1283): error C2065: 'ERROR_SUCCESS' : undeclared identifier
|
----2nd attempt----
So I put another header file in.
1 2 3
|
#include<winreg.h>
#include<winerror.h>
//other code unchanged
|
The C2065 error was gone, but the other error was still there.
----3rd attempt----
Then I did some googling about this error, some people said including windows.h would help, so I tried:
1 2 3 4
|
#include<Windows.h>
#include<winreg.h>
#include<winerror.h>
//other code unchanged
|
And got even more errors.
1 2 3 4
|
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(19787): error C3861: '__readfsdword': identifier not found
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8819): error C3861: '_InterlockedIncrement': identifier not found
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8828): error C3861: '_InterlockedIncrement': identifier not found
//and more of them...
|
----4th attempt----
Then I googled with key word "__readfsdword", seems it only works under x86 architecture. So I put it in:
1 2 3 4 5
|
#define _X86_
#include<Windows.h>
#include<winreg.h>
#include<winerror.h>
//other code unchanged
|
So...
1 2 3 4 5 6 7
|
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\kernelspecs.h(58): warning C4005: 'HIGH_LEVEL' : macro redefinition
1> C:\Program Files (x86)\Windows Kits\8.1\Include\shared\kernelspecs.h(55) : see previous definition of 'HIGH_LEVEL'
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5875): warning C4005: 'CONTEXT_CONTROL' : macro redefinition
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(3483) : see previous definition of 'CONTEXT_CONTROL'
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5876): warning C4005: 'CONTEXT_INTEGER' : macro redefinition
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(3484) : see previous definition of 'CONTEXT_INTEGER'
//and some more of them...
|
And now I am completely stuck, got no idea how to continue. Could anyone help? I am running 64bit Windows 7 and Visual Studio 2013.
And by the way, I have _AMD64_ defined in my compiler command line during those attempts.