OLE Error: CoInitialize has not been called (Views: 69)
OLE Error: CoInitialize has not been called
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
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.
OLE2, // <-- make sure to include this unit
Windows; // and others
CoInitialize(nil); // <-- manually call CoInitialize()
<< Back to main page