idhttp客户端post数据包,被服务端接收,我想在IdhttpserverCommandGet事件中处理客户端post过来的XML数据包,使用XMLdocumnt控件处理
IdhttpserverCommandGet事件中的大概代码如下:
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
    ServerMemo.Text:=(ARequestInfo.Params.GetText);
    XMLDoc.Active:=false;
    XMLDoc.XML.Text:=ServerMemo.Text;
    XMLDoc.Active:=true;   
    ..........//读取XML中节点的数值
    AResponseInfo.ContentText:=ResponseString;
end;
程序到调用XMLDoc的时就会出现这样的错误
project project1.exe raised exception class EoleException with message '尚未调用CoInitialize。'process stopped use step or run to continue
不明白“尚未调用CoInitialize”是什么意思,请大家帮忙解答。

解决方案 »

  1.   

    没调用你就调用就是了,嘿嘿。
    USES ACTIVEX单元
      

  2.   

    不是这原因才怪。。CSDN上每隔几天总有人问CoInitialize。。
    在任何讲COM编程的书上都应该有它。procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    begin
      CoInitialize(nil);//    ServerMemo.Text:=(ARequestInfo.Params.GetText);这句是显示吗?
    //在工作线程里面这样显示是很糟糕的写法    XMLDoc:=TXMLDocument.Create(self);//必须在本线程创建,不能使用创建于主线程的.
        
        XMLDoc.Active:=false;
        XMLDoc.XML.Text:=ServerMemo.Text;
        XMLDoc.Active:=true;   
        ..........//读取XML中节点的数值
        AResponseInfo.ContentText:=ResponseString;  CoUnInitialize;
    end;
      

  3.   

    哦,谢谢指导,呵呵,因为才刚开始用delphi开发网络方面的程序,原来写的都是数据库方面的,呵呵。再试试