Board index » delphi » D5: Problem with ActiveX object inside the Execute event of TIdTCPServer

D5: Problem with ActiveX object inside the Execute event of TIdTCPServer

I am trying to create an instance of Microsoft's DOM (MSXML) inside the
Execute event of the TIdTCPServer.  This is an ActiveX server.  The error
says "CoInitialize has not been called".  I guess it is because of Indy's
threading.  Any ideas to get around this?  I thought ActiveX stuff could
support threading.?

Here is the code:
( uses MSXML2_TLB )

procedure TfrmServer.tcpServExecute(AThread: TIdPeerThread);
var
  sMsg: string;
  sUser, sPsw,
  sUpdate: ShortString;
  User: TspankUser;
  dm: TdmMain;
  doc: IXMLDOMDocument2;
  docResponse: IXMLDOMDocument2;
  nod: IXMLDOMNode;
begin
  try
    try
      doc := CoDOMDocument30.Create;    <-  Exception raised right there **
      docResponse := CoDOMDocument30.Create;
      ....

Thanks.

 

Re:D5: Problem with ActiveX object inside the Execute event of TIdTCPServer


delphi_...@hotmail.com (Matt) wrote in <3aba6ba8$1_1@dnews>:

Quote
>I am trying to create an instance of Microsoft's DOM (MSXML) inside the
>Execute event of the TIdTCPServer.  This is an ActiveX server.  The error
>says "CoInitialize has not been called".  I guess it is because of Indy's
>threading.  Any ideas to get around this?  I thought ActiveX stuff could
>support threading.?

In the threads BeforeRun call CoInitialize (See WinAPI) and in the AfterRun
call CoUninitialize.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Other Threads