出现一个'尚未调用ConInitialize",的问题(25分)

  • 主题发起人 主题发起人 crazymoon
  • 开始时间 开始时间
C

crazymoon

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把一个窗体做进一个DLL,在此
窗体中用了ActiveX控件,出现了这个错误,"尚未调用ConInitialize",
应如何解决?
 
在程序开始的地方调用
ConInitialize(nil);
 
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.

 
在程序开始的地方调用
ConInitialize(nil);
加在哪啊?而且好像要声明个什么东西
 
到这里来看看,有很好的回答:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1219913
 
uses activex,

ConInitialize(nil);

用完了还得有一个unConInitialize(nil);
好象晕么写的,我忘 了,


 
把下面的代码添加到你的窗体代码里就行了
initialization
begin
CoInitialize(nil);
end;

finalization
begin
CoUninitialize;
end;
 
云行时出现一个
Access violation at address in ss.dll的误,
刚才那个问题 没了,这又是怎么回事?
 
能不能正常编译?
你是不是添加在代码的最末端?
 
form窗体的
end.之前,能编译
 
这是调用dll错误,你应该检查一下你的调用代码
 
user comobj,Activex
begin
Application.Initialize;
Application.ShowMainForm := False;
ConInitialize(nil);
Form1:=TForm1.create(Application)
Application.Run;
end.

Form1关闭时要在onclose中加入
unConInitialize;
 
接受答案了.
 
后退
顶部