[python-win32] Launching COM apps from Python

Mark Hammond mhammond at skippinet.com.au
Fri May 7 21:40:37 EDT 2004


You are trying to use a ProgID that does not exist.  A "ProgID" is really
just a mapping to its CLSID.  It sounds like your object is not registering
itself correctly.

Look in the registry - all COM objects have their name directly under
HKEY_CLASSES_ROOT.  Under that name, you will find a CLSID.  This CLSID will
then have a key under HKEY_CLASSES_ROOT\CLSID.  Look at the registry to
confirm that the names you tried do not exist as COM objects.

Otherwise, try using the CLSID of the object directly, instead of the
ProgID - just pass the IID string directly to Dispatch()

Mark.

> -----Original Message-----
> From: python-win32-bounces+mhammond=keypoint.com.au at python.org
> [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On
> Behalf Of Tony Cappellini
> Sent: Saturday, 8 May 2004 10:15 AM
> To: python-win32 at python.org
> Subject: [python-win32] Launching COM apps from Python
>
>
>
>
> I'm trying to launch an in-house COM-server from Python.
> I do have the IDL file that the TLB was created from but ....
>
> I haven't been to launch the program successfully yet.
> I've registered the app as a com server, run makepy and imported the
> resulting py file.
>
> I've tried following the examples in Programming Python on
> W32 as well.
>
> So I looked in the Win32com/test directory, at the test
> scripts for the
> Office Apps, trying to follow suit.
>
> I've tried this approach
> mytest = win32com.client.dynamic.Dispatch("mytest.Application")
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File
> "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
>     dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>   File
> "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line
> 91, in _GetGoodDispatchAndUserName
>     return (_GetGoodDispatch(IDispatch, clsctx), userName)
>   File
> "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line
> 79, in _GetGoodDispatch
>     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221005, 'Invalid class string', None, None)
>
>
> as well as
> mytest = win32com.client.dynamic.Dispatch("mytest")
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File
> "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
>     dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>   File
> "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line
> 91, in _GetGoodDispatchAndUserName
>     return (_GetGoodDispatch(IDispatch, clsctx), userName)
>   File
> "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line
> 79, in _GetGoodDispatch
>     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221005, 'Invalid class string', None, None)
>
>
> I've substituted the name "mytest" with the case-sensitive
> name from the
> IDL file.
>
> This COM stuff just drives me crazy.
>
> Would anyone mind pointing me in the right direction?
>
> thanks
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32




More information about the Python-win32 mailing list