1. for current user. They can simply modify belowregistry. 0=Enable, 1=Prompt
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings\Zones\2]
"1407"=dword:00000000
2.Use Group Policy API for all users. Maybe the app need haveAdministrator right.
Policy settings are specified by an administrator. This is incontrast to profile settings, that are specified by a user.
Below is C++ example to enable “'Allow programaticclipboard access”
#define INITGUID
#include <Guiddef.h>
#include <Prsht.h>
#include <Gpedit.h>
#define GPO_IE_REG_ZONE_2_PATH _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\Zones\\2")
BOOL SetGroupPolicy(HKEY hKey, LPCTSTR subKey, LPCTSTRvalueName, DWORD dwType, const BYTE* szkeyValue, DWORD dwkeyValue) ;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DWORD dwEnable = 0;
CoInitialize(NULL);
SetGroupPolicy(HKEY_LOCAL_MACHINE,GPO_IE_REG_ZONE_2_PATH,_T("1407"),REG_DWORD,NULL,dwEnable);
::CoUninitialize();
return 0;
}
BOOL SetGroupPolicy(HKEY hKey, LPCTSTR subKey, LPCTSTRvalueName, DWORD dwType, const BYTE* szkeyValue, DWORD dwkeyValue)
{
HKEY ghKey, ghSubKey, hSubKey;
LPDWORD flag = NULL;
IGroupPolicyObject *pGPO = NULL;
HRESULT hr =CoCreateInstance(CLSID_GroupPolicyObject, NULL, CLSCTX_ALL,IID_IGroupPolicyObject, (LPVOID*)&pGPO);
if(!SUCCEEDED(hr))
{
return FALSE;
}
if (RegCreateKeyEx(hKey, subKey, 0,NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hSubKey, flag) !=ERROR_SUCCESS)
{
return FALSE;
}
if(dwType == REG_SZ)
{
if(RegSetValueEx(hSubKey,valueName, 0, dwType, szkeyValue, strlen((char*)szkeyValue) + 1) !=ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
returnFALSE;
}
}
else if(dwType == REG_DWORD)
{
if(RegSetValueEx(hSubKey,valueName, 0, dwType, (BYTE*)&dwkeyValue, sizeof(dwkeyValue)) !=ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
returnFALSE; }
}
if(!SUCCEEDED(hr))
{
return FALSE;
}
if(pGPO->OpenLocalMachineGPO(GPO_OPEN_LOAD_REGISTRY)!= S_OK)
{
returnFALSE;
}
if(pGPO->GetRegistryKey(GPO_SECTION_USER,&ghKey)!= S_OK)
{
returnFALSE;
}
if(RegCreateKeyEx(ghKey, subKey, 0,NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &ghSubKey, flag) !=ERROR_SUCCESS)
{
RegCloseKey(ghKey);
return FALSE;
}
if(dwType == REG_SZ)
{
if(RegSetValueEx(ghSubKey,valueName, 0, dwType, szkeyValue, strlen((char*)szkeyValue) + 1) !=ERROR_SUCCESS)
{
RegCloseKey(ghKey);
RegCloseKey(ghSubKey);
returnFALSE;
}
}
else if(dwType == REG_DWORD)
{
if(RegSetValueEx(ghSubKey,valueName, 0, dwType, (BYTE*)&dwkeyValue, sizeof(dwkeyValue)) !=ERROR_SUCCESS)
{
RegCloseKey(ghKey);
RegCloseKey(ghSubKey);
return FALSE; }
}
GUID RegistryId = REGISTRY_EXTENSION_GUID;
if(pGPO->Save(false, true,const_cast<GUID*>(&RegistryId),const_cast<GUID*>(&CLSID_GPESnapIn)) != S_OK)
{
RegCloseKey(ghKey);
RegCloseKey(ghSubKey);
return FALSE;
}
pGPO->Release();
RegCloseKey(ghKey);
RegCloseKey(ghSubKey);
return TRUE;
}