关于多线程模式下的in-process com调用的问题(200分)

  • 主题发起人 liqunxin
  • 开始时间
L

liqunxin

Unregistered / Unconfirmed
GUEST, unregistred user!
一个简单的解析程序,server端收到数据,然后进行解析。server端基于多线程模式,
考虑到接口通用性,我直接调用微软的解析器。
这么调用
var
doc:eek:levariant;
begin
doc:=createoleobject('microsoft.xmldom');
end;
然而单线程模式下完全正常的程序,现在运行总是出错"尚未调用coInitialize"。
coInitialize不是在application初始化时自动调用的吗?
 
问题找到了,
You need to initialize the COM library on a thread before you call
any of the library functions except CoGetMalloc, to get a pointer to
the standard allocator, and the memory allocation functions.
在线程开始时调用coInitialize(nil)就解决了。

现在只剩一个问题:在多线程模式下,使用msxml是否合适?因为是多用户同时访问,
需要考虑性能影响。如果使用的话,怎么使用性能最好?

 
顶部