• Status: Open
  • Priority: Low
  • Security: Public
  • Views: 45
  • Last Modified:

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);
  DefaultInterface.GetData(bTime, lFirstIndex, lLastIndex, pBuffer, nValuesRead);
this function from .tlb file.

I want to call this function but this function does not accept olevarient.
I tried following way
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

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

please help me on this i stuck
Ankush Murkute
Ankush Murkute
1 Comment
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
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

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now