首页 > 编程知识 正文

加载控件异常怎么处理,控件未加载怎么处理

时间:2023-05-05 14:08:52 阅读:168931 作者:4911

1、问题说明:编写OCX,加载到本地静态html文件中,双击在IE中打开,即可成功加载OCX控件。 调用那个方法也是正常的。 将测试的html文件放入apache目录中,用IE打入localhost进行访问也是正常的,但部署到服务器上,用客户端PC访问服务器IP的方式无法加载OCX。

2 )根据问题解决、网上查询及以往对接经验,设定如下:

1 )在IE中加入受信任的web服务IP站点:

2 )仍然在可信站点界面将“定制级别”设置为“低”:

现在,您应该可以在从ip访问服务器页时加载ocx控件。

3、额外解决:

随后,ocx检查实现安全接口:当用HTML调用ocx控件时,【SCRIPT3:找不到成员。 】

我尝试了一下,但是通过添加IObjectSafety接口,可以在不设置IE的情况下成功加载OCX并调用该方法。

=========================================================================================

转载于3https://blog.csdn.net/laironggui/article/details/79422118

在HTML中调用OCX控件时,【SCRIPT3:中找不到成员。 【写了ocx控件,测试OK后,嵌入HTML中使用,发现死活不能调用方法,很气馁!

搜索方法,设定IE浏览器的权限就可以了。 启用“对未标记为安全运行脚本的activex控件初始化并运行脚本”。

这个方法并不是不行,而是要求所有用户都设定这个权限,显然不合适。

于是我继续研究方法,终于找到了解决的办法!

那就是实现ActiveX组件的IObjectSafety接口,并返回到脚本安全性。

具体来说,在h和cpp中添加以下代码。

1、OCXTestCtrl.h

////ActiveX控件的安全初始化: ISafeObject接口///isafeobjectdeclare _ interface _ map (begin _ interface _ part ) 实现iinterface )的gtinterfacesafetyoptions (/* [ in ] */refiidrid,/* [ out ] */dword _ RPC _ far * pdwsupporteded SetInterfaceSafetyOptions ) (/* [in] */REFIID riid,/* [in] */DWORD dwOptionSetMask,/* [ end _ interface _ part //ISafeObject 2,OCXTestCtrl.cpp

////ActiveX控件的安全初始化: ISafeObject接口////interfacemapforiobjectsafetybegin _ interface _ map (cocxtestctrl ) obj safe (end _ interface _ map (/iobjectsafetymemberfunctions//delegate addref,Release, queryinterfaceulongfarexportcocxtestctrl 33603360 xobjsafe 3360: addref ({ method _ prologue ) cocxtestctrl, obj safe } ulongfarexportcocxtestctrl : xobjsafe : release ({ method _ prologue (cocxtestctrl, objsafe ) returnpthihing } hresultfarexportcocxtestctrl :3360 xobjsafe : query interface (ref iid,void far * far * PPP ) } constdworddwsupportedbits=interfacesafe _ for _ untrusted _ caller|interfacesafe _ for _ untrusted _ data; constdworddwnotsupportedbits=~dwsupportedbits;//……………………………………………。 cstoplitectrl : xobjsafe : getinterfacesafetyoptions//allowscontainertoquerywhatinterfacesaresafeforwhat.we optimizingsignificantlybyignoringwhichinterfacethecalleris/aking for.hresultstdmethodcalltypecocxtestctrl 33603360 xobjsafe 3360: getinterfacesafetyoptions (/* [ in ] */refiiidresidresidestion pdwsupportedoptions,/* [ out ] */dword _ _ RPC _ far * pdwenabledoptions ) {} //does interface exist? IUnknown FAR* punkInterface; retval=pthis-externalqueryinterface (riid,) void * * (punk interface ); if (还原!=e _ no interface (//interfaceexistspunkinterface-release ); //release it--just checking! //wesupportbothkindsofsafetyandhavealwaysbothset,//regardlessofinterface * pdwsupportedoptions=* pdwenabledoptions=rd //e _ nointerfaceifqifailed }//cstoplitectrl 33603360 xobjsafe 3360: setinterfacesafetyoptions//since we ' realwaaar this is ano-brainer-- butwedochecktomake//suretheinterfacerequestedexistsandthattheoptionswe ' reasker . hresultstdmethodcalltypecocxtestctrl 3360: xobjsafe 3360: setinterfacesafetyoptions (/* [ in ] */refidrid,/* )/* [ in ] */dworddwenabledoptions ({ method _ prologue (cocxtestctrl,ObjSafe ) }/)。 IUnknown FAR* punkInterface; phis-externalqueryinterface (riid,) void * * ) punkInterface; 通用接口(//interfaceexistspunkinterface-release ); //release it--just checking! } else {//interface doesn ' texistreturnresultfromscode (e _ no interface ); //can ' tsetbitswedon ' tsupportif (dwoptionsetmaskdwnotsupportedbits (returnresultfromscode (e _ fail ) ); //can ' tsetbitswedosupporttozerodwenabledoptions=dwsupportedbits; //(wealreadyknowtherearenoextrabitsinmask ) if ) )!=dwoptionsetmask (returnresultfromscode (e _ fail ) ); //don ' tneedtochangeanythingsincewe ' realwayssafereturnresultfromscode (s _ ok ); (//

实例截图:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。