VC6.0 ATL方式的OCX去除安全警告框

发布时间:2014-10-23 23:25:17
来源:分享查询网

          在XXXCtrl.h的文件中加入以下步骤的内容           1、包含atlctl.h头文件            2、在class ATL_NO_VTABLE CXXXCtrl :                    public CComObjectRootEx<CComSingleThreadModel>,                    public CComCoClass<CXXXCtrl, &CLSID_XXXCtrl>,                    public IDispatchImpl<IXXXCtrl, &IID_IXXXCtrl, &LIBID_XXXXXLib>,                    public IObjectSafety //增加该部分           3、在BEGIN_COM_MAP(CXXXCtrl)                           COM_INTERFACE_ENTRY(IXXXCtrl)                           COM_INTERFACE_ENTRY(IDispatch)                           COM_INTERFACE_ENTRY(IObjectSafety)  //增加该部分                     END_COM_MAP()                增加以下两个函数                    STDMETHODIMP GetInterfaceSafetyOptions( REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions )                    {                              *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;                              *pdwEnabledOptions = *pdwSupportedOptions;                               return S_OK;                     }                    STDMETHODIMP SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions)                    {                               return S_OK;                    }            到此操作完成,试试你的OCX就可以去除安全警告框。    

返回顶部
查看电脑版