How to add URL to the trusted zone in Internet Explorer?

后端 未结 7 881
北海茫月
北海茫月 2020-12-31 22:12

How can I add an URL to the trusted site? It seems that there are stored in the registry, but where exactly?
The hints I\'ve googled so far weren\'t helpfull.

Th

7条回答
  •  天涯浪人
    2020-12-31 22:26

    Check this solution at CodeGuru forums.

    In summary, this code uses the COM library, a library which you did say you wished to avoid. However, there is no workaround this situation. Another thing to mention is that this code is written in C++, as the guy who wrote it, CorithMartin, ported it from C#.

    #include "windows.h"
    #include "stdafx.h"
    #include "urlmon.h"
    #using 
    #include 
    #include 
    using namespace System;
    using namespace System::Runtime::InteropServices;
    #define MAX_LOADSTRING 100
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        // constants from urlmon.h
        const int URLZONE_LOCAL_MACHINE = 0;
        const int URLZONE_INTRANET = URLZONE_LOCAL_MACHINE + 1;
        const int URLZONE_TRUSTED = URLZONE_INTRANET + 1;
        const int URLZONE_INTERNET = URLZONE_TRUSTED + 1;
        const int URLZONE_UNTRUSTED = URLZONE_INTERNET + 1;
        const int URLZONE_ESC_FLAG = 0x100;
        const int SZM_CREATE  = 0;
        const int SZM_DELETE  = 0x1;
    
        HRESULT hr;
        IInternetSecurityManager *pSecurityMgr;
        LPCWSTR sites = SysAllocString(L"http://*.mydomain.com");
    
        CoInitialize(NULL);
    
        hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, (void**)&pSecurityMgr);
    
        pSecurityMgr->SetZoneMapping(URLZONE_TRUSTED, sites, SZM_CREATE);
    
        pSecurityMgr->Release();
    
        return 0;
    }
    

提交回复
热议问题