• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            ActiveX 安全問題

            轉載自:http://blog.csdn.net/bwmwm/article/details/4536217

            工作中寫了一個MFC ActiveX,測試的時候,發現IE6和IE8修改了安全設置后能夠正常運行,IE7和別的瀏覽器則始終無法正常運行,經過多方查找,發現缺少一些安全信息注冊,添加下列代碼后能夠正常運行了。

             首先定義三個函數:

            HRESULT CreateComponentCategory(CATID catid, WCHAR *catDescription)  
            {  
                ICatRegister 
            *pcr = NULL ;  
                HRESULT hr 
            = S_OK ;  
                hr 
            = CoCreateInstance(CLSID_StdComponentCategoriesMgr,   
                    NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (
            void**)&pcr);  
                
            if (FAILED(hr))  
                    
            return hr;  
                
            // Make sure the HKCR/Component Categories/{..catid}  
                
            // key is registered.  
                CATEGORYINFO catinfo;  
                catinfo.catid 
            = catid;  
                catinfo.lcid 
            = 0x0409 ; // english  
                size_t len;  
                
            // Make sure the provided description is not too long.  
                
            // Only copy the first 127 characters if it is.  
                
            // The second parameter of StringCchLength is the maximum  
                
            // number of characters that may be read into catDescription.  
                
            // There must be room for a NULL-terminator. The third parameter  
                
            // contains the number of characters excluding the NULL-terminator.  
                hr = StringCchLength(catDescription, STRSAFE_MAX_CCH, &len);  
                
            if (SUCCEEDED(hr))  
                
            {  
                    
            if (len>127)  
                    
            {  
                        len 
            = 127;  
                    }
              
                }
                 
                
            else  
                
            {  
                    
            // TODO: Write an error handler;  
                }
              
                
            // The second parameter of StringCchCopy is 128 because you need   
                
            // room for a NULL-terminator.  
                hr = StringCchCopy(catinfo.szDescription, len + 1, catDescription);  
                
            // Make sure the description is null terminated.  
                catinfo.szDescription[len + 1= '/0';  
                hr 
            = pcr->RegisterCategories(1&catinfo);  
                pcr
            ->Release();  
                
            return hr;  
            }
              

             

            HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
            {
                
            // Register your component categories information.
                ICatRegister *pcr = NULL ;
                HRESULT hr 
            = S_OK ;
                hr 
            = CoCreateInstance(CLSID_StdComponentCategoriesMgr, 
                    NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (
            void**)&pcr);
                
            if (SUCCEEDED(hr))
                
            {
                    
            // Register this category as being "implemented" by the class.
                    CATID rgcatid[1] ;
                    rgcatid[
            0= catid;
                    hr 
            = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
                }

                
            if (pcr != NULL)
                    pcr
            ->Release();
                
            return hr;
            }

             

            HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid)
            {
                ICatRegister 
            *pcr = NULL ;
                HRESULT hr 
            = S_OK ;
                hr 
            = CoCreateInstance(CLSID_StdComponentCategoriesMgr, 
                    NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (
            void**)&pcr);
                
            if (SUCCEEDED(hr))
                
            {
                    
            // Unregister this category as being "implemented" by the class.
                    CATID rgcatid[1] ;
                    rgcatid[
            0= catid;
                    hr 
            = pcr->UnRegisterClassImplCategories(clsid, 1, rgcatid);
                }

                
            if (pcr != NULL)
                    pcr
            ->Release();
                
            return hr;
            }

             

            然后在STDAPI DllRegisterServer(void)和STDAPI DllUnregisterServer(void)中添加下列代碼:

            STDAPI DllRegisterServer(void)中:

                HRESULT hr;
                hr 
            = CreateComponentCategory(CATID_SafeForInitializing, 
                    L
            "Controls safely initializable from persistent data!");
                
            if (FAILED(hr))
                    
            return hr;
                hr 
            = RegisterCLSIDInCategory(CLSID_SafeItem, 
                    CATID_SafeForInitializing);
                
            if (FAILED(hr))
                    
            return hr;
                
            // Mark the control as safe for scripting.
                hr = CreateComponentCategory(CATID_SafeForScripting, 
                    L
            "Controls safely  scriptable!");
                
            if (FAILED(hr))
                    
            return hr;
                hr 
            = RegisterCLSIDInCategory(CLSID_SafeItem, 
                    CATID_SafeForScripting);
                
            if (FAILED(hr))
                    
            return hr;

             

            STDAPI DllUnregisterServer(void)中:

                HRESULT hr;
                hr
            =UnRegisterCLSIDInCategory(CLSID_SafeItem, 
                    CATID_SafeForInitializing);
                
            if (FAILED(hr))
                    
            return hr;
                hr
            =UnRegisterCLSIDInCategory(CLSID_SafeItem, 
                    CATID_SafeForScripting);
                
            if (FAILED(hr))
                    
            return hr;

             

            其中CLSID_SafeItem就是就是瀏覽器中使用的clsid。

            posted on 2012-09-04 23:11 楊粼波 閱讀(617) 評論(0)  編輯 收藏 引用 所屬分類: C++

            久久久久久国产精品美女| 亚洲午夜精品久久久久久人妖| 2021国产精品午夜久久| 国产毛片欧美毛片久久久| 国产精品久久久久久吹潮| 久久久久国产一区二区| 久久人人爽人人爽人人片AV不| 欧美精品一本久久男人的天堂| 久久乐国产精品亚洲综合| 天天爽天天狠久久久综合麻豆| 99久久亚洲综合精品网站| 国产69精品久久久久久人妻精品| 国产精品视频久久| 久久久久亚洲AV片无码下载蜜桃| 久久久久中文字幕| 一本色道久久88—综合亚洲精品| 久久www免费人成精品香蕉| 亚洲精品tv久久久久久久久| 久久97久久97精品免视看| 亚洲精品乱码久久久久久按摩| 久久一本综合| 97久久精品人人澡人人爽| 久久精品午夜一区二区福利| 亚洲?V乱码久久精品蜜桃| 国产精品欧美久久久久无广告| 热re99久久6国产精品免费| 久久中文字幕人妻丝袜| 女同久久| 久久久久噜噜噜亚洲熟女综合| 久久精品国产一区| 久久精品午夜一区二区福利| 精品久久久久久国产| 亚洲AV伊人久久青青草原| 久久精品国产国产精品四凭| 久久99热国产这有精品| 久久久精品人妻一区二区三区蜜桃 | 99久久免费国产精精品| 老色鬼久久亚洲AV综合| 久久亚洲精精品中文字幕| 亚洲αv久久久噜噜噜噜噜| 亚洲国产精品无码久久98|