Hi,
Many things are wrong with the original code you posted.
1.) You should check the return value of RegOpenKeyEx for ERROR_SUCCESS.
2.) You are trying to read the registry value... but you open the key with only KEY_SET_VALUE.
3.) You are allocating a dynamic array when your obviously using a constant buffer size.
4.) Some missing function parameters.
5.) You should use the correct delete[] operator.
Something like this should work:
#define BUFFER_SIZE 1024 //add this to your header
HKEY hKey;
DWORD dwErr = NO_ERROR;
dwErr = RegOpenKeyEx (HKEY_CURRENT_USER,L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3",NULL,KEY_SET_VALUE|KEY_QUERY_VALUE,&hKey);
if(ERROR_SUCCESS == dwErr)
{
BYTE data[BUFFER_SIZE] = {0};
DWORD dwType = REG_NONE;
dwErr = RegQueryValueEx(hKey,L"1803",NULL,&dwType,data,&buffersize);
if(ERROR_SUCCESS == dwErr && REG_DWORD == dwType)
{
*((LPDWORD)data) = 0;
dwErr = RegSetValueExW(hKey,L"1803",0,REG_DWORD,data,sizeof(DWORD));
}
RegCloseKey (hKey);
}
Also... if you are on a 64 bit operating system and writing a 32 bit application you will need to add KEY_WOW64_64KEY to your RegOpenKeyEx flags.
Best Wishes,
-David Delaune