First I thought it was due to registry virtualization, but then I read that it doesn't apply to the subkeys that I am using.
Anyone have any experience with this, or maybe can spot the error? Too many experiments right now, so hard to keep all the balls in the air at the same time ^^
Code: Select all
#include <windows.h>
int main()
{
HKEY phkResult;
DWORD retVal;
//Open registry key and add file path as a new value
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCWSTR)L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &phkResult);
if(retVal == ERROR_SUCCESS)
{
retVal = RegSetValueEx(phkResult, (LPCWSTR)L"Something", 0, REG_SZ, (LPBYTE)L"C:\\Something.exe", MAX_PATH + 1);
RegCloseKey(phkResult);
}
return 0;
}