Websnap application update for delphi 2005 - CoInitialize error

We have a current product written on the Delphi 6 website that I am trying to update to work under delphi 2005. It uses ADO and the launch error - β€œCoInitialize” was not called. "The only links I can find in this error, they point to IntraWeb and something like ServerController, which, I'm not sure, is relevant to me. Any number of calls to CoInitialize (nil) does not affect.

Am I wasting my time launching this or can I launch it in 2005, or is a later release coming to this?

+4
source share
1 answer

CoInitialize must be called in a thread that accesses COM (for example, in any thread that accesses your database through ADO). It is called in the main thread by Delphi by default, but you need to explicitly call it in other threads.

Try calling it in the OnActivate event and call CoUninitialize in the OnDeactivate event.

Also make sure that ADOTables and ADOConnections are not open at design time. Otherwise, the application will try to use COM before you call CoInitialize .

If all else fails, try overriding the web form constructor and skip CoInitialize there before you inherit. Remember to call CoUninitialize in the destructor.

+5
source

All Articles