资源描述:
《activex控件在ie中弹出安全警告的解决办法》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、activex控件在IE中弹出安全警告的解决办法写的activex控件在IE中弹出安全警告的解决办法#include//在控件头文件中加入:DECLARE_INTERFACE_MAP()BEGIN_INTERFACE_PART(ObjectSafety,IObjectSafety)STDMETHOD(GetInterfaceSafetyOptions)(REFIIDriid,DWORD__RPC_FAR*pdwSupportedOptions,DWORD__RPC_FAR*pdwEnab
2、ledOptions);STDMETHOD(SetInterfaceSafetyOptions)(REFIIDriid,DWORDdwOptionSetMask,DWORDdwEnabledOptions);END_INTERFACE_PART(ObjectSafety)//在控件的CPP文件中加入:BEGIN_INTERFACE_MAP(CVP2PCtrl,COleControl)INTERFACE_PART(CVP2PCtrl,IID_IObjectSafety,ObjectSafety)END_INTE
3、RFACE_MAP()//ImplementationofIObjectSafetySTDMETHODIMPCVP2PCtrl::XObjectSafety::GetInterfaceSafetyOptions(REFIIDriid,DWORD__RPC_FAR*pdwSupportedOptions,DWORD__RPC_FAR*pdwEnabledOptions){METHOD_PROLOGUE_EX(CVP2PCtrl,ObjectSafety)if(!pdwSupportedOptions
4、
5、!pdw
6、EnabledOptions){returnE_POINTER;}*pdwSupportedOptions=INTERFACESAFE_FOR_UNTRUSTED_CALLER
7、INTERFACESAFE_FOR_UNTRUSTED_DATA;*pdwEnabledOptions=0;if(NULL==pThis->GetInterface(&riid)){TRACE("Requestedinterfaceisnotsupported.");returnE_NOINTERFACE;}//Whatinter
8、faceisbeingcheckedoutanyhow?OLECHARszGUID[39];inti=StringFromGUID2(riid,szGUID,39);if(riid==IID_IDispatch){//Clientwantstoknowifobjectissafeforscripting*pdwEnabledOptions=INTERFACESAFE_FOR_UNTRUSTED_CALLER;returnS_OK;}elseif(riid==IID_IPersistPropertyBag
9、
10、r
11、iid==IID_IPersistStreamInit
12、
13、riid==IID_IPersistStorage
14、
15、riid==IID_IPersistMemory){//ThosearethepersistenceinterfacesCOleControlderivedcontrolssupport//asindicatedinAFXCTL.H//Clientwantstoknowifobjectissafeforinitializingfrompersistentdata*pdwEnabledOptions=
16、INTERFACESAFE_FOR_UNTRUSTED_DATA;returnS_OK;}else{//Findoutwhatinterfacethisis,anddecidewhatoptionstoenableTRACE("Wedidn'taccountforthesafetyofthisinterface,andit'sonewesupport...");returnE_NOINTERFACE;}}STDMETHODIMPCVP2PCtrl::XObjectSafety::SetInterfaceS
17、afetyOptions(REFIIDriid,DWORDdwOptionSetMask,DWORDdwEnabledOptions){METHOD_PROLOGUE_EX(CVP2PCtrl,ObjectSafety)OLECHARszGUID[39];//Whatisthisinterfaceanyway?//WecandoaquicklookupintheregistryunderHKEY_C