First time asking a question so hope I'm doing it right...
I'm trying to write a small program to change the reg key for the home page of internet explorer but each time I run it I'm getting the error that the key location open was unsuccessful. Any ideas why? (Tried running in admin)
//this string array will be the value for the new home page (w/ null termination)
char newHomePage[] = "https://www.youtube.com/watch?v=gwJ_LgYYvpU \0";
HKEY homePageKey = NULL; //handle for the key once opened
//Open reg key we wish to change, if this fails then abort
//reg key for home page
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"\\SOFTWARE\\Microsoft\\Internet Explorer\\Main", 0, KEY_SET_VALUE, &homePageKey) == ERROR_SUCCESS)
{
printf("Key location open successful \n");
if (RegSetValueExW(homePageKey, L"Start Page", 0, REG_SZ, (LPBYTE)&newHomePage, sizeof(char)) == ERROR_SUCCESS)
{
printf("Key changed in registry \n");
}
else
{
printf("Key not changed in registry \n");
printf("Error %u ", (unsigned int)GetLastError());
}
RegCloseKey(homePageKey);
}
else
{
printf("Error: %u \n", (unsigned int)GetLastError());
printf("Key location open UNsuccessful \n");
system("pause");
RegCloseKey(homePageKey);
return 0;
}
return 0;