Subj : COM from Delphi To : borland.public.cpp.borlandcpp From : "Trevor Macdonald" Date : Fri Oct 24 2003 07:49 am This is a multi-part message in MIME format. ------=_NextPart_000_00F0_01C399FB.088571B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I but am having problems getting data from the COM that was written in = Delphi and am trying to use it in CPP. This is the definition of pContourLine typedef struct tagPCONTOURLINE { float x; float y; } PCONTOURLINE; PCONTOURLINE pContourLine[32676]; .. .. DECLARE_INTERFACE_( Contr, IUnknown ) { // IUnknown methods STDMETHOD (QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; STDMETHOD_(ULONG, AddRef) ( THIS ) PURE; STDMETHOD_(ULONG, Release) ( THIS ) PURE; // function getnextcontour(var ContourLine:PContourLine; var = np:integer):boolean;stdcall; This is the Dephi function =09 STDMETHOD_ (BOOL, getnextcontour1)(THIS_ PCONTOURLINE *pContourLine, = int *np) PURE; }; typedef Contr * LPCONTR; .. Contr* pContr; HRESULT hr; hr =3D CoCreateInstance( = CLSID_Contr,NULL,CLSCTX_INPROC_SERVER,IID_Contr,(void**) &pContr ); .. .. while (getnextcontour(&pContr->pContourLine, &np) && np > 0) { for (cnt=3D0; cnt< np; cnt++) { fLat =3D pContourLine[cnt].y; fLon =3D pContourLine[cnt].x; } } When I compile I get this error x:\WIP\COMIntro\COM.cpp(223): error C2664: 'getnextcontour' : cannot = convert parameter 1 from 'PCONTOURLINE (*)[32676]' to 'PCONTOURLINE *' If I remove the & from the beginning of pContourLine it compiles without = any errors but flat and flon are always 0.00 so=20 I am not getting the pointer to the data in the dll. Apparently there is some issue with getting an HRESULT back from a = Delphi function but we are getting a return of TRUE or FALSE from = 'getnextcontour1' What am I doing wrong so as not to get the pointer correctly. Thanks Trevor ------=_NextPart_000_00F0_01C399FB.088571B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I but am having problems getting data = from the COM=20 that was written in Delphi
and am trying to use it in = CPP.
 
This is the definition of = pContourLine

typedef struct = tagPCONTOURLINE
{
float=20 x;
float y;
} PCONTOURLINE;
PCONTOURLINE=20 pContourLine[32676];
.
.

DECLARE_INTERFACE_( Contr, = IUnknown=20 )
{
  // IUnknown methods
STDMETHOD = (QueryInterface)(THIS_ REFIID=20 riid, void **ppv) PURE;
  STDMETHOD_(ULONG, AddRef) ( THIS )=20 PURE;
  STDMETHOD_(ULONG, Release) ( THIS ) = PURE;

//   =20 function  getnextcontour(var ContourLine:PContourLine; var=20 np:integer):boolean;stdcall; This is the Dephi function
  =20
STDMETHOD_ (BOOL, getnextcontour1)(THIS_ PCONTOURLINE = *pContourLine, int=20 *np) PURE;
};
typedef Contr * LPCONTR;

.

 
 

Contr* pContr;

HRESULT hr;

hr =3D CoCreateInstance(=20 CLSID_Contr,NULL,CLSCTX_INPROC_SERVER,IID_Contr,(void**) &pContr );

.
.
  while (getnextcontour(&pContr->pContourLine, = &np)=20 && np > 0)
  {
    for (cnt=3D0; cnt< = np;=20 cnt++)
    {
      fLat =3D=20 pContourLine[cnt].y;
      fLon =3D=20 pContourLine[cnt].x;
    }
  }

When I = compile I get=20 this error
x:\WIP\COMIntro\COM.cpp(223): error C2664: = 'getnextcontour' :=20 cannot convert parameter 1 from 'PCONTOURLINE (*)[32676]' to = 'PCONTOURLINE=20 *'

If I remove the & from the beginning of pContourLine it = compiles=20 without any errors but flat and flon are always 0.00 so
I am not = getting the=20 pointer to the data in the dll.

Apparently there is some issue = with=20 getting an HRESULT back from a Delphi function but we are getting a = return of=20 TRUE or FALSE from 'getnextcontour1'

What am I doing wrong so as = not to=20 get the pointer = correctly.

Thanks
Trevor

------=_NextPart_000_00F0_01C399FB.088571B0-- .