Communicating with MSVC++ via COM: how?
Eric Brunel
eric.brunel at N0SP4M.com
Mon Jan 12 05:22:39 EST 2004
Mark Hammond wrote:
> Eric Brunel wrote:
>
>> This script doesn't work: the call to docs.CloseAll fails with the error:
>>
>> Traceback (most recent call last):
>> File "test.py", line 13, in ?
>> docs.CloseAll()
>> TypeError: object of type 'int' is not callable
>
>
> This is because docs.CloseAll is making the call, and returning an int.
> This, docs.CloseAll() is attempting to call that int.
Hi Mark,
Thanks for your answer. We finally figured out this one, but the problem lies a
bit farther in the script:
bkpts.AddBreakpointAtLine(86)
The method AddBreakpointAtLine takes an *optional* parameter which is the line
number on which to put the breakpoint. But bkpts.AddBreakpointAtLine actually
calls the method AddBreakpointAtLine with no parameter, so I just can't figure
out how to call the method *with* a parameter...
> It looks very much like you have no makepy support for MSVC built.
>
> Just after the line:
> app = win32com.client.Dispatch('MSDev.Application')
> Try adding:
> app = win32com.client.gencache.EnsureDispatch(app)
>
> That should force makepy, and everything should start working.
I tried what you suggest, but it didn't work: I get the following error:
>>> app = win32com.client.gencache.EnsureDispatch(app)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "H:\Tools\Python\bin\Windows\Python21\win32com\client\gencache.py", line
423, in EnsureDispatch
disp = win32com.client.Dispatch(prog_id)
File "H:\Tools\Python\bin\Windows\Python21\win32com\client\__init__.py", line
95, in Dispatch
return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo,
UnicodeToString, clsctx)
File "H:\Tools\Python\bin\Windows\Python21\win32com\client\__init__.py", line
26, in __WrapDispatch
typeinfo = dispatch.GetTypeInfo()
File "H:\Tools\Python\bin\Windows\Python21\win32com\client\dynamic.py", line
438, in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: MSDev.Application.GetTypeInfo
Trying to force the generation of the support files via an explicit makepy.py
didn't work either: doing a Dispatch('MsDev.Application') still doesn't get the
right type. Forcing the type by doing Dispatch('MsDev.Application',
resultCLSID="{the-class-id}") seems to work, but apparently, the generated class
knows nothing about the types of its members and simple things as:
app.Visible = 1
fail with a traceback (something like "incorrect type for variable" - sorry for
the imprecision: we have a French Windows, so the message I get is in
French...). Getting an attribute like app.Debugger seems to work, but printing
it says:
<COMObject Debugger>
so the object is a dynamic one, and also knows nothing about its type.
Is there any solution to our problems?
TIA
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list