Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
OLE Error: CoInitialize has not been called Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
11-Sep-02
Category
OLE
Language
Delphi 5.x
Views
70
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

OLE Error: CoInitialize has not been called

Answer:

In a project that needed to display HTML documents, I decided to use the 
TWebBrowser control. I had used this handy ActiveX control successfully in other 
projects before.

This application was an MDI application, written in Delphi 5. As a 'specialty' I 
had installed a beta version of Internet Explorer on my system. I am not sure which 
of this is responsible for it, but when I would call the function in my application 
to display the HTML document, the TWebBrowser element could not be instantiated.
Instead I would receive an error message:

'CoInitialize has not been called'

The surprising thing is that the webbrowser control shows fine in design mode! I 
checked and TWebBrowser was properly installed. The underlieing DLL was also 
registered properly. A call of

regsvr32 shdocvw.dll

did not help. Finally I manually called the CoInitialize() function. I had to add 
OLE2 to the list of used units. A good place to do this is the initialization part 
as the sample snippet below shows.


1   uses
2     OLE2, // <-- make sure to include this unit
3     Windows; // and others
4   
5   initialization
6     CoInitialize(nil); // <-- manually call CoInitialize()
7   
8   end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC