Board index » delphi » Setting variants during runtime

Setting variants during runtime

Hi,

I have a function that creates an OLE object and passes the result to a
variant.

In another function I allow the user to pass an OLE command that needs to be
executed.

At least, that's what I want to do.

An example:

function1
var
  myVar: OleVariant;
begin
  myVar := CreateOLEObject('word.application');
end;

function2 (Command: String): String
begin
  Result := myVar.Command;

// to execute for example:
// Result := myVar.ActivePrinter;
end;

I want to use the string in function2 as identifier for my variant to do
something. How do I do this?

I have tried everything, but I'm stuck.

Gr. Peter.

 

Re:Setting variants during runtime


  Look up the TAutoObject's GetIDsOfNames and Invoke functions in the Delphi
Help.  That should give you what you need.  However, it is not as generic as
you have shown...different functions may well take different parameters and
return a different result type.  Just passing the string is not enough
unless your parameter list and return type are always the same.
-Howard

Other Threads