Sign-up....

线程中调用COM

我在线程中操作数据库,包括连接和读操作,总是得到一个错误信息"Automation error

CoInitialize has not been called"。是不是因为我没有对线程进行CoInitializeEx操作吗?

怎样进行这个操作,有例子吗?

[130 byte] By [msdn] at [2007-8-14 12:04:58]
# 1 Re: 线程中调用COM

yes,你没有进行COM初始化,也就是没有为COM建个自己的小房间,hoho

supergreenbean at 2004-9-3 8:06:58 >
# 2 Re: 线程中调用COM

有没有例子呀?多谢了

hohhot at 2004-9-3 10:00:58 >
# 3 Re: 线程中调用COM

google一下有di,关于vb实现多线程的,不过,是老外的

supergreenbean at 2004-9-3 11:40:58 >
# 4 Re: 线程中调用COM

我的研究结果:

Private Declare Function CoInitialize Lib "ole32.dll" (ByVal pvReserved As Long) As Long

Private Declare Sub CoUninitialize Lib "ole32.dll" ()

在com调用前使用res = CoInitialize(0)

调用结束后使用CoUninitialize

其中Dim res&

hohhot at 2004-9-3 11:58:41 >
# 5 Re: 线程中调用COM

我上次贴的东西好像只能在VB环境中运行成功,如果编译成exe再运行,还是会crash。

各位大侠帮忙呀

hohhot at 2004-9-6 16:12:29 >
# 6 Re: 线程中调用COM

严重关注

hwshws123 at 2005-4-18 21:41:52 >

VB

All Classified