ComObj DispatchInvoke does not support indexed property wrapper
Original Reporter info from Mantis: Arioch
-
Reporter name:
Original Reporter info from Mantis: Arioch
- Reporter name:
Description:
http://qc.embarcadero.com/wc/qcmain.aspx?d=115373
Code like
var V: Variant;
V := CreateOLEObject('Word.Application');
V.CentimetersToPoints(1.0);
should fail, because WordApplication.CentimetersToPoints(const single); is not a method, but an indexed property getter.
In http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/winunits-base/src/comobj.pp?view=markup
1244 DISPATCH_METHOD:
1245 if assigned(Result) and (CallDesc^.ArgCount=0) then
1246 InvokeKind:=DISPATCH_METHOD or DISPATCH_PROPERTYGET;
The guard "(CallDesc^.ArgCount=0)" is wrong and should be removed.
Additional information:
RRuz checked the bug happens in FPC http://stackoverflow.com/questions/16279098/unspecified-error-when-calling-word-centimeterstopoints-via-ole/16280000#comment23306226_16280000
The "(CallDesc^.ArgCount = 0) and " is wrong shouldbe removed.
Quoting IDispatch original documentation http://msdn.microsoft.com/en-us/library/windows/desktop/ms221486.aspx
Some languages cannot distinguish between retrieving a property and calling a method. In this case, you should set the flags DISPATCH_PROPERTYGET and DISPATCH_METHOD.
That is what should be done. And erroneous check for non-zero ArgCount is breaking correct behavior.
Mantis conversion info:
- Mantis ID: 24352
- Platform: Win32 + MS Office COM/OLE
- Version: 1.0.9 (SVN)
- Fixed in version: 3.0.0
- Fixed in revision: 26860 (#132366e4)