[python-win32] BSTR

Reiner M. Stoss rstoss at hrz1.hrz.tu-darmstadt.de
Fri Apr 14 23:57:45 CEST 2006


Mark et al.,

> Python will *always* (unless an object's typelib indicated otherwise) pass
> a VT_BSTR when a string literal is specified.  I'm afraid I can't
> speculate on what the problem may otherwise be.

As additional information to our problem I want to mention
that other methods which need a string (path+filename)
do work, e.g. CCDCamera.OpenFile and CCDCamera.SaveFile,
only CCDCamera.SaveImage doesn't and raises an exception
error (Invalid Input), as mentioned by Aleksandar in a previous
post.

So I have contacted the author of MaxIm DL and he wrote:
"That is quite strange, since CCDCamera.SaveImage and Document.SaveFile
declare their filename arguments identically, in (1) the C++ source code,
(2) the dispatch table, and (3) the ODL file."

Meanwhile he has installed Python 2.4.3 and PythonWin build 208
and with the code I did provided he was able to reproduce the
problem. He has then:
"set a breakpoint inside MaxIm DL, trapping when CCDCamera.SaveImage was
called.  Guess what?  The variant argument that was supposed to contain the
filename was VT_ERROR.  Little wonder we were rejecting the call."

He continues:
"Next, I looked at PythonWin's object browser, per your instructions.  But
here I see something different.  I assume you're opening the "Registered
Type Libraries" category, expanding 'MaxIm.Objects', and 'Type Library'
within that again.  What I see is a long list of entries saying,

  'The type info can n... = 'The type info can not be loaded!'

I can't say whether this indicates a bug in PythonWin or whether my registry
is corrupted somehow."

So my question is, do these entries mean anything at all
and could they explain why the method SaveImage doesn't work?
I see such entries however for other applications too and their
methods do work.

I also want to add that in PythonWin's COM browser
the CCDCamera.SaveImage function lib looks okay.
It says, see here:
http://www.reinerstoss.de/Python/MaxIm_SaveImage.jpg

The entries for the two methods that do work are, see here:
http://www.reinerstoss.de/Python/MaxIm_OpenFile_SaveFile.jpg

So everything seems okay, right? Still the question is
why "The variant argument that was supposed to contain the
filename was VT_ERROR".

BTW, the code looks like this:
---
import win32com.client, time

CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera')

CCDCamera.LinkEnabled = True

if CCDCamera.LinkEnabled == False:
     print 'Failed to start camera.'

exp = int(raw_input('Exposition[sec]: '))

CCDCamera.Expose(exp, 1, 0)
while CCDCamera.ImageReady == False:
     time.sleep
print 'Done'

time.sleep(3)
CCDCamera.SaveImage('S:/Reiner/MaxIm/1.fit')
---

and the raised error message looks like this:
---
Traceback (most recent call last):
  File "S:\Reiner\MaxIm\maxim1.py", line 18, in ?
    CCDCamera.SaveImage('S:/Reiner/MaxIm/1.fit')
  File "C:\Programme\Python24\Lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__
    raise pythoncom.com_error, details
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None)
---

Any help much appreciated.

Thanks,
Reiner




More information about the Python-win32 mailing list