HRESULT CoInitialize( LPVOID pvReserved )的使用?(100分)

N

nbdhj

Unregistered / Unconfirmed
GUEST, unregistred user!
在使用delphi编写的一个com对象时,应用程序调用时,说CoInitialize尚未调用,但我直接
写入CoInitialize(null),编译时又说没定义?
 
请把ActiveX单元Uses进去。
 
For the EXE server, we simply create a standard EXE application: File | New Application. Delphi automatically adds a default form to our server that acts as the server's interactive user interface. If we don't want an EXE server to show this form, we simply add the following lines to our project's DPR file:

begin
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(...);
Application.Run;
end.

Note that it is important to have the Application.Initialize call as the first statement in the DPR file. This enables the ComObj module to initialize the COM runtime by calling CoInitialize/Ex at startup.

If you are migrating an EXE application to a COM server and forgot to call Application.Initialize, you'll get a "CoInitialize has not been called" error at the first statement that makes a COM call that requires exporting/importing a COM interface. This is a common error when migrating standalone applications into COM servers or upgrading a COM server from an older version of Delphi to Delphi 5.
 
多人接受答案了。
 
顶部