Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : Using COM in Indy servers
| Subject: | Using COM in Indy servers |
| Posted by: | "Philip von Melle" (philip.vonmel..@globetrotter.de) |
| Date: | 27 Jul 2006 03:19:03 |
I need to use COM in the OnCommandGet() eventhandler of TIdHTTPServer. As
that's executed within a thread (not the main one) I need to call
CoInitialize(nil, COINIT_MULTITHREADED) before using it an CoInitialize
when I'm done.
Certainly I could call it from within the OnCommandGet() but that's
probably not very efficient. So where to best place those calls? Two ideas
sprign to my mind:
a) Derive from TIdContext, assign it to the ContextClass property of
TIdHPPTServer and overide the constructor/destructor to call
CoInitialize/CoUnitialize.
b) Derive from TIdThreadWithTask override the constructor/destructor to
call CoInitialize/CoUnitialize there and assign its class to the
ThreadClass property of TIdSchedulerOfThread(Pool).
Any comments what would work best?
Regards, Philip