idhttpserver 事件 CommandGet小问题

xogirl 2004-09-10 11:03:36
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”是什么意思,请大家帮忙解答。
...全文
751 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
halfdream 2004-09-10
  • 打赏
  • 举报
回复
没调用你就调用就是了,嘿嘿。
USES ACTIVEX单元
xogirl 2004-09-10
  • 打赏
  • 举报
回复
呵呵,可以了,结帖罗。
xogirl 2004-09-10
  • 打赏
  • 举报
回复
哦,谢谢指导,呵呵,因为才刚开始用delphi开发网络方面的程序,原来写的都是数据库方面的,呵呵。再试试
halfdream 2004-09-10
  • 打赏
  • 举报
回复
不是这原因才怪。。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;
xogirl 2004-09-10
  • 打赏
  • 举报
回复
好像不是这个原因。测试过了,不是这个原因
xogirl 2004-09-10
  • 打赏
  • 举报
回复
是吗?以前没有遇到过这样的问题,先试试。谢谢了

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧