Hello!
I am trying to read a value from the registry, but I can't get it to work.
Everything compiles, but RegQueryValueEx keeps producing an error.
this is the code:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
HKEY hKey = 0;
unsigned char buf[20];
DWORD dwBufSize = 20;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Activision\\Call of Duty 4"), NULL, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
MessageBox(0, TEXT("Can't open key."), NULL, MB_OK);
if(RegQueryValueEx(hKey, TEXT("codkey"), NULL, NULL, (LPBYTE)buf, &dwBufSize) != ERROR_SUCCESS)
MessageBox(0, TEXT("Can't query key."),NULL, MB_OK);
cout << "key value is '" << buf << "'\n";
RegCloseKey(hKey);
cin.ignore();
return 0;
}
I have read through tonnes of examples, and can't figure out why this wont work =/
anyone have any ideas?