Link to home
Start Free TrialLog in
Avatar of Ankush Murkute
Ankush Murkute

asked on

olevarient parameter throws exception passing to .type libaray com object in delphi.

I have generated  .type library from some .dll which com dll.

//procedure TMDF4Reader.GetData(bTime: Integer; lFirstIndex: Integer; lLastIndex: Integer;
                              out pBuffer: OleVariant; out nValuesRead: Integer);
begin
  DefaultInterface.GetData(bTime, lFirstIndex, lLastIndex, pBuffer, nValuesRead);
end;
this function from .tlb file.

I want to call this function but this function does not accept olevarient.
I tried following way
var
vData : olevarient;


  vData := VarArrayCreate([0,0], varDispatch); // A Variant array

  boun.cElements := 1;
  boun.lLbound := 0;
  SafeArray :=  SafeArrayCreate(VT_DISPATCH, 1, @bounds);
if SafeArray <> nil then
begin

    TVarData(vData).VType := (VT_ARRAY  or VT_VARIANT or VT_DISPATCH);
    TVarData(vData).VArray  := PVarArray(SafeArray);
end;
     MDF4.GetData(1, 1, 10, &vData, &n); // Get the data form the time signal


please help me on this i stuck
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

It seems there out 2 out parameters in your function

I'd call it as
GetData(bTime: Integer; lFirstIndex: Integer; lLastIndex: Integer; 
                              var pBuffer: OleVariant; out nValuesRead: Integer);

Open in new window

If you pass pBuffer as out then any value sored there will be cleared
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.