| |

VerySource

 Forgot password?
 Register
Search
View: 904|Reply: 4

The dll contains a form, and there is an ActiveX control in the form. Why does it always say that CoInitialize is not av

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-21 12:40:01
| Show all posts |Read mode
I have a dll file that contains a form and an ActiveX control inside the form. I want to call a function in the dll in another project without displaying the form in the dll. The system always reports an error: CoInitialize Who can tell me why? How should it be achieved? The following is a function in the form that my Dll contains:
procedure Info;
  var
    Form1: TForm1;
  Begin
      Form1: = TForm1.Create (nil);
      ShowMessage ('hello3');
      Form1.Free;
  End; I tried it, other space is OK, ActiveX control is not enough, master click it! !! !!
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-6 12:15:01
| Show all posts
Write the following code at the end of your form pas file:

initialization
  CoInitialize (nil);
finalization
  CoUnInitialize;

end.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-7 21:45:01
| Show all posts
procedure Info;
var
  Form1: TForm1;
Begin
  CoInitialize (Nil);
  Form1: = TForm1.Create (nil);
  ShowMessage ('hello3');
  Form1.Free;
  CoUninitialize;
End;
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-10 22:30:01
| Show all posts
The control of the com object requires CoInitialize and CoUninitialize. . . .
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-19 16:15:02
| Show all posts
COINNITIALIZE is called every time a method of the COM object is called
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list