I wrote the code below to edit a registry value:
#include <windows.h>
#include <string.h>
int main(int argc, char* argv[]) {
HKEY hkey = NULL;
const char* evtwvr = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Event Viewer";
const char* exepath = "file://C:\\Users\\MrUser\\Desktop\\temp.exe;
LONG rgdt = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCSTR)evtwvr, 0 , KEY_WRITE, &hkey);
if (rgdt == ERROR_SUCCESS) {
RegSetValueEx(hkey, (LPCSTR)"MicrosoftRedirectionUrl", 0, REG_SZ, (unsigned char*)exepath, strlen(exepath));
RegCloseKey(hkey);
}
return 0;
}
It simple edits the registry key and writes the exe path as a value.
But I want to do it like this:
myprogram.exe C:\Users\User\MrUser\temp.exe
and pass the input parameter into the registry value.