I\'m having trouble calling a function that has a floating point argument and a floating point result, using IDispatch.Invoke
.
Here\'s a minimal reproductio
Well, that was a head-scratcher. The documentation for this "method" is very misleading, it is not a method. It behaves more like an indexed property and requires the DISPATCH_METHOD | DISPATCH_PROPERTYGET flags. CComPtr doesn't support that, you'll need to spin this by hand. This code worked:
CComVariant result;
CComVariant centimeters((float)2.0);
DISPID dispid;
LPOLESTR name = L"CentimetersToPoints";
HRESULT hr = wordapp->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
assert(SUCCEEDED(hr));
DISPPARAMS dispparams = { ¢imeters, NULL, 1, 0};
hr = wordapp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD | DISPATCH_PROPERTYGET, &dispparams, &result, nullptr, nullptr);
assert(SUCCEEDED(hr));