请大家帮忙翻译一篇文章赏我全分给你谢谢了

来源:百度知道 编辑:UC知道 时间:2024/09/21 19:41:37
The way around this is to build into the code a defensive coding technique which will attempt to load the required component and if the call to cocreateinstance fails because the component is not registered then the code will register the component on the computer. This requires that the component is located in the same place as your executable so that the component can be found by the code. The class CRegisterComObject provides four functions

These functions work as there names imply. With the name of the dll/exe to be registered/unregistered passed as a parmeter. It should be noted here that the name to pass is the dll or executable name of the binary file which is not necassarily the name of the Component interface that you were trying to load.
Using the Class
First of all the value returned from CoCreateInstance when a class is not defined is

which I usually define as above. Second, in order to call CoCreateInstance you must also include the _i.c f

该办法是建立到代码的是防御性的编码技术,它会尝试加载所需组件,如果电话cocreateinstance失败,因为组件是没有登记,然后将代码登记组件对计算机。这就要求组件是设在同一地点,因为你的可执行程序,使该组件可以很容易找到工作守则。每班cregistercomobject提供四个职能

这些职能工作,因此,顾名思义。该人的姓名的DLL文件/可执行文件,以注册/未注册的通过,作为一个参数。这里应当指出这一名称通过,是DLL文件或可执行文件的名称二进制文件,它是不是necassarily组件的名称界面,你要加载的。
用一流
首先,所有的价值回来cocreateinstance时,一类是没有界定,是

我通常定义如上。第二,为了呼吁cocreateinstance你还必须包括_i.c文件生成时,组件/秒建成。
一旦你已包括这些,你可以尝试负荷你的组件。有过两次类似的方法,你可以做到这一点。你可以使用typelibrary定义指针或ccomptr模板代码作风等,都是十分相似。

第二条路将同型图书馆定义指针将改为
内部代码取得当前的Windows路径,以便它可致电regsvr32.exe 。然后设置参数,并传递给regsvr32节目包括dll. /可执行文件名称,如果需要。
代码,然后电话createprocess创建一个新的背景,过程,处理登记的组成部分。代码,然后等待该进程的完成利用指定的时间waitfor它的定义是:

在registercomobject刑事诉讼法档案。
所有职能工作,对这一制度的建立需要字符串传递给regsvr32.exe文件,然后等待它完成。
该示范工程随之而来的阶级允许验车登记,移走及测试组件,因为他们一起走。但必须指出,即使为例作品完美地就一个可执行文件,同时不能说,为DLL文件。看来, DLL文件是没有卸下从记忆immeadiately这么说,如果你设法永恒的,它经过检验后,它或它的注册代号报道取得圆满成功,但如果你的测试代码为DLL文件,这也报道取得圆满成功。话虽如此说,它并不是让推荐人登记册,并删除组件,因为他们去,这个代码可以书面向绕开的绊脚石的组件不被注册和取消