Article View: borland.public.cppbuilder.nativeapi
Article #13573Re: Using Delphi Dll in BCB application
From: Remy Lebeau (TeamB)
Date: Sat, 04 Oct 2003 21:44
Date: Sat, 04 Oct 2003 21:44
42 lines
2788 bytes
2788 bytes
"Seabass" <sbsoftea@ww-ei.nl> wrote in message
news:3f7f2049@newsgroups.borland.com...
> Type
> TSendMess = procedure (sb1:pchar;sb2:pchar);stdcall;
> TCommon = procedure();stdcall;
> TCommon2 = procedure (sb1:pchar) ;stdcall;
> TCommon3 = function (sb1:pchar):boolean ;stdcall;
In your C++ code, you declared your event types to accept pointers to
members of your struct, but in your Delphi code above, you are declaring
them to accept pointers to standalone functions instead, not class/struct
methods. The two are not the same. You need to either:
1) change your C++ code to not use class/struct members (why are you using
that, anyway? You didn't show the code that actually assigns them):
typedef void (__stdcall *TSendMess)(const char*,const char*);
typedef void (__stdcall *TCommon)(void);
typedef void (__stdcall *TCommon2)(const char*);
typedef bool (__stdcall *TCommon3)(const char*);
2) change your Delphi code to accept class/struct members, ie:
Type
TSendMess = procedure(sb1: PChar; sb2: PChar) of object; stdcall;
TCommon = procedure() of object; stdcall;
TCommon2 = procedure(sb1: PChar) of object; stdcall;
TCommon3 = function(sb1: PChar): boolean of object; stdcall;
> When I try to call pChat, the break point I set at the C++ end gets
> called, but when looking at the parameters, I noticed that the first
> parameter contained the data of the second parameter and the data
> in the second parameter was just some random junk.
Probably because the function signatures don't match, so the hidden' this'
pointer that is normally passed in your C++ code is not being passed in the
Delphi code, so the parameters are pushed onto the stack differently.
Gambit
Technical Details
Message-ID:
<3f7f3ed0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f7f2049@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c7642e4ad15381e3 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-04 15:40:32 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f7f2049@newsgroups.borland.com> Subject: Re: Using Delphi Dll in BCB application Date: Sat, 4 Oct 2003 14:44:10 -0700 Lines: 44 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.137.75 Message-ID: <3f7f3ed0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1065303760 67.22.137.75 (4 Oct 2003 14:42:40 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail