Help requested -- importing stuff from a .COM DLL into python

John D Salt jdsalt_AT_gotadsl.co.uk
Wed May 31 13:35:25 EDT 2006


I wonder if some kind soul can help me in my struggle with DLLs?

I am trying -- not because I want to, but because I have been told to -- 
to import things from an API that exists as a bunch of .COM DLLs.  

I had originally hoped to get them into a Python 2.4 program by a simple 
import statement.  This does not appear to work, so I secured a copy of 
win32com, and have proven that it works to the extent of opening a M$ 
Word application.

The same approach with the DLLS I actually need to use consistently fails 
with the message "Invalid class string" (full traceback included below, I 
doubt that it helps).  After a couple of afternoons of vigorous easter-
egging, I have not hit upon a valid class string, and my childish 
assumption that it would be one of the names listed in the API 
ocumentation is obviously wrong.  Staring at the DLL contents with 
PEBrowse tells me nothing useful.

Does anyone with experience of getting .COM stuff from DLLs know where I 
am going wrong?

(Alternatively, can anyone who has got Python to use the MooD API tell me 
how?)

I have no experience of .COM up to this point, and am hoping to keep it 
that way once this nonsense is done with.

Thanks for any assistance, and all the best,

John.

- - - - - - - -  cut here  - - - - - - - - 

Traceback (most recent call last):
  File "D:\Program Files\MooD\2006\MooDAPI\APIstrangler0_1.py", line 470, 
in ?
    thing = win32com.client.Dispatch("MooDAPI.Object.Info") # Fails, 
"Invalid class string
  File "D:\Python24\Lib\site-packages\win32com\client\__init__.py", line 
95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName
(dispatch,userName,clsctx)
  File "D:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
98, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "D:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 
78, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)



More information about the Python-list mailing list