- WebBrowser Control浏览网页过程中会跳出如下对话框:
- 此对话框大体意思是提示需要保存cookies数据在本地,需用户确认。
- 如何禁止弹出此对话框:
- 在IInternetSecurityManager::ProcessUrlAction中允许或禁止cookie相关URL action(但悲催的是进行cookie相关操作时,此函数没有被调用。。。)
1 if(URLACTION_COOKIES_THIRD_PARTY == dwAction ||
2 URLACTION_COOKIES_SESSION_THIRD_PARTY == dwAction ||
3 URLACTION_COOKIES_SESSION == dwAction ||
4 URLACTION_COOKIES_ENABLED == dwAction ||
5 URLACTION_COOKIES == dwAction)
6 {
7 dwPolicy = URLPOLICY_DISALLOW;
8 *(DWORD*)pPolicy = dwPolicy;
9 return S_OK;
10 } - 一种偷懒的办法是把所有URL都映射到URLZONE_UNTRUSTED(禁止cookie)或URLZONE_LOCAL_MACHINE(允许cookie):
1 STDMETHOD (MapUrlToZone)(LPCWSTR pwszUrl,DWORD *pdwZone,DWORD dwFlags)
2 {
3 *pdwZone = URLZONE_UNTRUSTED;//URLZONE_LOCAL_MACHINE;
4 return S_OK;
5 } - 还有一种办法是修改注册表(包括前面文章的提交数据表单时的对话框,也可以用此方法):
- HKEY_LOCAL_MACHINE//Software//Microsoft//Windows//CurrentVersion//Internet Settings//zones//3
-
#define URLACTION_COOKIES_THIRD_PARTY 0x00001A05 #define URLPOLICY_ALLOW 0x00 #define URLPOLICY_QUERY 0x01 #define URLPOLICY_DISALLOW 0x03
- 参考: