problem with COM interface

Giganews Newsgroups
Subject: problem with COM interface
Posted by:  William Meyer (meyer.w…
Date: 23 Jul 2007

I am trying to make use of a COM server from a 3rd party supplier.

The vendor provides this snippet:

  #include "VendorApi.h"
  IVendorEncodeCtrl *pFM;
  short nDeviceNum = 0;
  lResult = CreateEncObj( &pFM, nDeviceNum );
  if ( lResult < 0 )
      // failed

I tried to replicate that, but found that I need a little different
code to even approach parity with theirs:

  Encoder: IVendorComApiDisp;
  EncodeControl: IVendorEncodeCtrl;

Then later, on a button:

procedure TForm1.btnCreateEncodeClick(Sender: TObject);
  nDeviceNum: Integer;
  res : Integer;
  Encoder.CreateEncObj( @EncodeControl, nDeviceNum, res );

When I try to compile, the compiler complains that the encode control
is not of the same type as the formal parameter, but the prototype of
that procedure, from the TLB.pas file, is here:

  procedure CreateEncObj(out pDecoderControl: IVendorEncodeControl;
nDeviceNum: Integer; out lResult: Integer ); dispid 9;

Plowing through sketchy docs and C++ demo code always leaves me a
little dizzy, but if you can see what I am missing here, I would love
to know.