• <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 楊粼波 閱讀(619) 評論(0)  編輯 收藏 引用 所屬分類: C++

            熟妇人妻久久中文字幕| 国产午夜精品久久久久免费视| 久久精品国产精品亚洲| 久久www免费人成看国产片| 免费精品久久天干天干| 久久久久无码精品国产不卡| 国产精品欧美久久久天天影视| 狠狠色综合网站久久久久久久| 中文精品99久久国产 | 久久精品嫩草影院| 久久久久99精品成人片| 亚洲综合熟女久久久30p| 亚洲国产精品久久| 久久亚洲精品无码AV红樱桃| 久久久久国产精品麻豆AR影院| 久久久久亚洲AV无码网站| 伊人伊成久久人综合网777| 国产精品青草久久久久福利99 | 老色鬼久久亚洲AV综合| 久久久久人妻一区精品| 77777亚洲午夜久久多喷| 久久人妻少妇嫩草AV蜜桃| 久久er国产精品免费观看2| 久久人人爽人人爽人人AV| 久久国产AVJUST麻豆| 久久久精品日本一区二区三区| 青青国产成人久久91网| av午夜福利一片免费看久久| 日本久久久久亚洲中字幕| 777午夜精品久久av蜜臀| 狠狠色丁香久久婷婷综合蜜芽五月| 久久国产精品二国产精品| 国产呻吟久久久久久久92| 久久综合九色综合97_久久久| 久久久久亚洲AV无码网站| 久久av无码专区亚洲av桃花岛| 99蜜桃臀久久久欧美精品网站| 精品综合久久久久久98| 亚洲国产美女精品久久久久∴| 新狼窝色AV性久久久久久| 国产精品久久久久久吹潮|