COM错误 - 紧急帮助 [英] COM Error -- Urgent help
问题描述
全部,
我在访问线程中的COM对象时遇到问题。确切地说,
假设我有一个GenericFunctions类定义为
如下:
import win32com.client,pythoncom,thread
ie = win32com.client.Dispatch(''internetexplorer.appl ication'')
ie.Visible = 1
class GenericFunctions:
def __init __(自我):
print"在Generic Functions的构造函数中
def MyNavigate(self,dest):
ie.Navigate(dest)
现在有另一个文件Main.py定义如下:
import win32com.client,pythoncom,thread
*
obj = GenericFunctions()
class Mainclass:
def __init __(self);
print"在Main类的构造函数中
def threadFunction(self,dest):
pythoncom.CoInitialize()
d = pythoncom.CoGetInterfaceAndReleaseStream(s,
pythoncom.IID_IDispatch)
my_ie = win32com.client。派遣(d)
obj.func(dest)#这是一个错误。
pythoncom.CoUninitialize()
if __name__ == " __ main __":
s = pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,i * e)
thread.start_new_thread(self.nav,(s,' 'www.google.com'')
基本上,我想在
threadFunction()中访问GenericFunctions类的对象。但是我能够执行
my_ie.Navigate(" google.com")。但那不是我想要的。我不知道b $ b知道错误在哪里....
请尽快让我知道解决方案...
Teja.P
HI all,
I have a problem in accesing COM objects in threads. To be precise,
lets assume that I have a class GenericFunctions which is defined as
follows:
import win32com.client, pythoncom, thread
ie=win32com.client.Dispatch(''internetexplorer.appl ication'')
ie.Visible=1
class GenericFunctions:
def __init__(self):
print "In Constructor of Generic Functions"
def MyNavigate(self,dest):
ie.Navigate(dest)
Now there is another file Main.py which is defined as follows:
import win32com.client, pythoncom, thread
from GenericFunctions import *
obj = GenericFunctions()
class Mainclass:
def __init__(self);
print "In Constructor of Main class"
def threadFunction(self,dest):
pythoncom.CoInitialize()
d=pythoncom.CoGetInterfaceAndReleaseStream(s,
pythoncom.IID_IDispatch)
my_ie=win32com.client.Dispatch(d)
obj.func(dest) # this is gving an error.
pythoncom.CoUninitialize()
if __name__ == "__main__":
s=pythoncom.CoMarshalInterThreadInterfaceInStream( pythoncom.IID_IDispatch,i*e)
thread.start_new_thread(self.nav, (s,''www.google.com'')
Basically, I want to access object of GenericFunctions class inside
threadFunction(). However I was able to execute
my_ie.Navigate("google.com"). But that was not I wanted. I am not
knowing where the error is....
Please let me know the solution ASAP...
Teja.P
推荐答案
嗨!
..func(未定义......
@ -salutations
-
Michel Claveau
Hi!
..func( is not defined...
@-salutations
--
Michel Claveau
Méta-MCI写道:
Méta-MCI wrote:
嗨!
.func(未定义......
@ -salutations
-
Michel Claveau
Hi!
.func( is not defined...
@-salutations
--
Michel Claveau
对不起。通过func(dest)我的意思MyNavigate(dest)。请你帮忙
me out out ...
Thnks,
Teja.P >
Teja写道:
Teja wrote:
对不起。通过func(dest)我的意思是MyNavigate(dest)你可以帮忙吗
我出去...
I am sorry. By func(dest) I meant MyNavigate(dest). Can u please help
me out...
这里没有人可以读懂你的想法。请你发布实际代码
使用, *和*你得到的错误。
< / F>
nobody here can read your mind. please post the code you''re actually
using, *and* the error you''re getting.
</F>
这篇关于COM错误 - 紧急帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!