threading and internet explorer com
Roger Upole
rupole at hotmail.com
Fri Jan 28 01:29:08 EST 2005
You'll need to call pythoncom.CoInitialize() in each thread.
Roger
"James" <c00lways at gmail.com> wrote in message
news:41f9777f_2 at news.tm.net.my...
> hi,
>
> i'm using python 2.4 with pywin32...
> I've tried to use internet explorer control with a class.
> it was fine until i decided to inherit thread for the class...
>
> class domain01(threading.Thread):
> def __init__(self):
> #blabla
> threading.Thread.__init__(self)
>
> def run(self):
> self.ie = win32com.client.Dispatch('InternetExplorer.Application.1') #this
> line gives error if i use .start(), but if i use .run.. no error...
> self.ie.Visibble = 1
> print "running"
>
>
>
> xyz = domain()
> xyz.start()
>
> ===========
> this is what i get:
> Exception in thread Thread-23:
> Traceback (most recent call last):
> File "C:\Python24\lib\threading.py", line 442, in __bootstrap
> self.run()
> File "C:\python2exe\domain01.py", line 41, in run
> self.dologin()
> File "C:\python2exe\domain01.py", line 56, in dologin
> self.ie=win32com.client.Dispatch('InternetExplorer.Application.1')
> File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
> dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
> 91, in _GetGoodDispatchAndUserName
> return (_GetGoodDispatch(IDispatch, clsctx), userName)
> File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
> 79, in _GetGoodDispatch
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
>
>
>
> =====
> but if i run:
> xyz = domain()
> xyz.run()
>
> ##no error! it's weird....
>
> anyone know how to solve this problem?
>
> thank you :)
>
> best regards,
>
> James
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
More information about the Python-list
mailing list