Was recently working for a client and need to read a value from registry. So I wanted to start off by trying something simple, reading the system Guid from the registry. This is the code that I'm using and I'm having trouble figuring out how to read certain data properly. I found out how to read DWORD's from here but that doesn't work with reading the system Guid from registry. Also, I'm compiling for 64-bit. Here is the code that I've been using
#include <iostream>
#include <string>
#include <Windows.h>
#include <processthreadsapi.h>
#include <tchar.h>
#include <cstring>
int main()
{
DWORD val;
DWORD dataSize = sizeof(val);
if (ERROR_SUCCESS == RegGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", "MachineGuid", RRF_RT_ANY, nullptr, &val, &dataSize))
{
printf("Value is %i\n", val);
}
else
{
printf("Read Error");
};
system("pause");
return 1;
};
It seems like no matter what I try, I keep getting the Read Error. I've been trying new things and reading articles online for the past hour and 15 minutes-ish. Decided to make a post and see if anyone could help me out. Any help is appreciated! (Also, I used Visual Studio, should you need to know for any reason). Thanks in advance!