[python-win32] comtypes: Problem with passing string argument
Einar Sørheim
einar at ife.no
Tue Jan 9 08:53:51 CET 2007
Thomas Heller wrote:
>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
>
>
Interface code was generated automatically, deleting the files in the
'gen' folder and re-generating the interface files does not help.
win32com works as expected on this part of the code, their interface
code looks like the following:
class _FluidDepoWaxDataLayer(DispatchBaseClass):
CLSID = IID('{FF3D17D3-69D4-4BC9-8173-7BDBBDDC4FE3}')
coclass_clsid = IID('{F6A1D76E-C0AF-4A99-9D35-DDE8C3DF1B3A}')
def AddDepoWaxCase(self, DepoWaxCase=defaultNamedNotOptArg):
return self._ApplyTypes_(1610809367, 1, (3, 0), ((16393, 3),),
'AddDepoWaxCase', None,DepoWaxCase
)
def AddFluid(self, Fluid=defaultNamedNotOptArg):
return self._ApplyTypes_(1610809358, 1, (3, 0), ((16393, 3),),
'AddFluid', None,Fluid
)
def CheckCompatibility(self, DatabasePath=defaultNamedNotOptArg):
return self._oleobj_.InvokeTypes(1610809374, LCID, 1, (2, 0),
((8, 1),),DatabasePath
)
......
vtables entry is :
(( 'CheckCompatibility' , 'DatabasePath' , None , ), 1610809374,
(1610809374, (), [ (8, 1, None, None) ,
(16386, 10, None, None) , ], 1 , 1 , 4 , 0 , 148 , (3, 0,
None, None) , 0 , )),
However win32com fails at a later stage using a companion com library, I
will make a separate post about this problem.
thanks,
Einar Sørheim
More information about the Python-win32
mailing list