Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2017-09-29
Low Priority
Last Modified: 2017-10-18
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
Question by:Ankush Murkute
1 Comment
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 42318148
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question