[python-win32] comtypes: Problem with passing string argument

Thomas Heller theller at ctypes.org
Mon Jan 8 17:46:40 CET 2007


Einar Sørheim schrieb:
> I have a com library that I have a hard time getting to work, some of it 
> works in win32com, some in comtypes.
> Have a question first for comtypes(using python2.4 and svn checkout 
> 3.jan07 of comtypes):
> The following code fails at the last step:
>         self.dl = comtypes.client.GetModule(r"C:\Program Files\Common 
> Files\Calsep\PvtsDataLayer.dll")
>         self.fl = comtypes.client.GetModule(r"C:\Program Files\Common 
> Files\Calsep\PvtsDataModel.dll")
>         self.datalayer = 
> comtypes.client.CreateObject(self.dl.FluidDepoWaxDataLayer)
>         self.fluid = comtypes.client.CreateObject(self.fl.Fluid)
>         cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program 
> Files\Calsep\Sample Programs\FlashOSDatabase.fdb")
> Errormessage:
>   File "mtucpvt.py", line 46, in Connect
>     cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program 
> Files\Calsep\Sample Programs\FlashOSDatabase.fdb")
> ValueError: Procedure probably called with too many arguments (4 bytes 
> in excess)
> 
> The generated inteface code looks like:
> _FluidDepoWaxDataLayer._methods_ = [
>     COMMETHOD([dispid(1745027104), 'propput'], HRESULT, 'UseDatabaseFormat',
>               ( ['in'], PvtsDLUseDatabaseFormat, 'None' )),
>     COMMETHOD([dispid(1745027104), 'propget'], HRESULT, 'UseDatabaseFormat',
>               ( ['retval', 'out'], POINTER(PvtsDLUseDatabaseFormat), 
> 'None' )),
>     COMMETHOD([dispid(1610809375)], HRESULT, 'IsConnectedAsReadOnly',
>               ( ['retval', 'out'], POINTER(VARIANT_BOOL), 'None' )),
>     COMMETHOD([dispid(1610809374)], HRESULT, 'CheckCompatibility',
>               ( ['in'], BSTR, 'DatabasePath' ),
>               ( ['retval', 'out'], POINTER(c_short), 'None' )),
> 
> Any ideas on what is wrong here?

This looks like some problem with the interface code.  Was it generated or
written manually?  Does (re-)generating the module help?  Are you sure
that the type library is up-to-date?

If you also have problems using the object in win32com, what are the symptoms?

Thomas



More information about the Python-win32 mailing list