Go Premium for a chance to win a PS4. Enter to Win


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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

916 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