I'm trying to invoke a COM object's method. The method (in OLEView) looks like this:-
VARIANT_BOOL GetValues(
[out] rsValues** values,
[in, optional] rsCategory* category,
[in, optional] rsProcess* process);
The last two parameters are optional, and I want to 'omit' them from the call (Just passing NULL doesn't work).
My understanding is that all the COM wrappers generated by the Delphi/C++Builder type library importers will convert each passed parameter to a variant. But to pass an 'omitted' parameter I think I have to construct a special Variant like this.
varOpt.vt = VT_ERROR;
varOpt.sCode = DISP_E_PARAMNOTFOUND;
This seems to mean I can't use any of the auto-generated generated component wrappers.
How (using C++Builder or Delphi - I should be able to convert Delphi to C++) can I call the method, and pass an 'omitted' variant?
Update
Here's how I tried to call the method, following the advice in David Heffernan's answer.
procedure TForm38.Wibble(obj : IrsObject);
var vals : IrsValues;
begin
ps.GetValues(vals, emptyparam, emptyparam);
But this gives this error:
[DCC Error] E2010 Incompatible types: 'IrsCategory' and 'OleVariant'
[DCC Error] E2010 Incompatible types: 'IrsProcess' and 'OleVariant'
As I'm using the non "Disp" object, I believe I'm using early binding.
I'm trying to avoid posting a 45000 line foo_TLB.pas file, but here (I hope) are the relevant sections.
IrsCategory = interface;
IrsCategoryDisp = dispinterface;
IrsProcess = interface;
IrsProcessDisp = dispinterface;
// *********************************************************************//
// Interface: IrsObject
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {861817F7-EA49-49D1-89FC-395BCA57E342}
// *********************************************************************//
IrsObject = interface(IDispatch)
['{861817F7-EA49-49D1-89FC-395BCA57E342}']
...
function GetValues(out values : IrsValue;
const Category: IrsCategory;
const Process: IrsProcess):): WordBool; safecall;
...
end;
// *********************************************************************//
// Interface: IrsObjectDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {861817F7-EA49-49D1-89FC-395BCA57E342}
// *********************************************************************//
IrsObjectDisp = dispinterface ... // basically the same, repeated