【ATL】注册插件成功后自动设置浏览器允许弹出窗口注册表

STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
HRESULT hr = E_FAIL;

static const wchar_t szUserSwitch[] = L"user";

if(pszCmdLine != NULL)
{
if(_wcsnicmp(pszCmdLine,szUserSwitch,_countof(szUserSwitch)) == 0)
ATL::AtlSetPerUserRegistration(true);
}

if(bInstall)
{
hr = DllRegisterServer();
if(FAILED(hr))
DllUnregisterServer();

// 操作注册表(允许阻止的浏览器弹出窗口)
HKEY hKEY;
LPBYTE path_Get = new BYTE[256];
DWORD type = REG_BINARY;
DWORD dwBytes = 254;

LPSTR data_set = "Software\\Microsoft\\Internet Explorer\\New Windows\\Allow";

if(::RegOpenKeyExA(HKEY_CURRENT_USER,data_set,NULL,KEY_READ,&hKEY) == ERROR_SUCCESS)
{
if(::RegQueryValueExA(hKEY,"要设置的域名",NULL,&type,path_Get,&dwBytes) != ERROR_SUCCESS)
{
LPBYTE mContent = new BYTE[2];
mContent[0] = 0x00;
mContent[1] = 0x00;

CRegKey key;
key.Create(L"Software\\Microsoft\\Internet Explorer\\New Windows\\Allow");
key.SetBinaryValue(L"要设置的域名",mContent,2);

key.Close();
}
}

::RegCloseKey(hKEY);

::MessageBoxA(NULL,"您可以正常使用ActiveX插件功能","插件安装成功",MB_OK | MB_ICONINFORMATION);
}
else
hr = DllUnregisterServer();

return hr;
}

  

posted @ 2015-07-17 13:24  star丶清影  阅读(617)  评论(0编辑  收藏  举报