Board index » delphi » Delphi DLL Types

Delphi DLL Types

Hi,

We have an application already build in Visual Basic and we just
bought Delphi to enhance it. So, I just wrote a dll with Delphi. My
problem is that everytime I want to access it from Visual Basic, I get
the bad dll calling convention... My function in Delphi is defined as
integer and I pass from vb an integer. when I do the declaration from
VB, I also use integer. Tried it with string type and still does not
work.

Does anybody know if there's sone special rules to follow when
declaring types from Delphi to VB ? Anybody know where I can find a
small sample that would show me how to build a dll for VB.

Thanks for you help,
Pierre Fillion

 

Re:Delphi DLL Types


Quote
pfill...@infobahnos.com (Anonymous) wrote:
> We have an application already build in Visual Basic and we just
> bought Delphi to enhance it. So, I just wrote a dll with Delphi. My
> problem is that everytime I want to access it from Visual Basic, I get
> the bad dll calling convention... My function in Delphi is defined as
> integer and I pass from vb an integer. when I do the declaration from
> VB, I also use integer. Tried it with string type and still does not
> work.

If you gave a source example of your Delphi function and your VB import code,
it would be easier to figure out where you went wrong.

All the best,
Lars F.
--
/ Mr.Lars Fosdal    / Falcon AS   (a REUTERS company) / Tel.+47 22831310
/ lfos...@falcon.no / Stranden 1, N-0250 OSLO, Norway / Fax.+47 22831290

Re:Delphi DLL Types


There are two ways to pass arguments:
- by Value and
- by Reference.

Have you mentioned the correct form? VB assumes 'by Reference' as
a default, Delphi uses 'by Value' as standard. Therefore
   VB:     Function Test(i As Integer) As Integer
is NOT the same as
   DELPHI: function Test(i:Integer): Integer;

Use either
   VB:     Function Test(byVal i As Integer) As Integer
   DELPHI: function Test(i: Integer): Integer;
or
   VB:     Function Test(byRef i As Integer) As Integer
   DELPHI: function Test(var i: Integer): Integer;

When using Strings:
   VB:     function Test(s As String) As Integer
   DELPHI: function Test(s: pChar): Integer;

Hope this helps!

Re:Delphi DLL Types


Quote
lfos...@falcon.no (Lars Fosdal) wrote:
>pfill...@infobahnos.com (Anonymous) wrote:
>> We have an application already build in Visual Basic and we just
>> bought Delphi to enhance it. So, I just wrote a dll with Delphi. My
>> problem is that everytime I want to access it from Visual Basic, I get
>> the bad dll calling convention... My function in Delphi is defined as
>> integer and I pass from vb an integer. when I do the declaration from
>> VB, I also use integer. Tried it with string type and still does not
>> work.
>If you gave a source example of your Delphi function and your VB import code,
>it would be easier to figure out where you went wrong.
>All the best,
>Lars F.
>--

Hey man, isn't there any comp.lang.pascal.delphi group for this?

Re:Delphi DLL Types


In article <42nn3n$...@shum.cc.huji.ac.il>,
Quote
Alex Shnitman <i...@inna.slip.huji.ac.il> wrote:

:Hey man, isn't there any comp.lang.pascal.delphi group for this?

In fact

 comp.lang.pascal.delphi.databases     Database aspects of Borland Delphi.
 comp.lang.pascal.delphi.components    Writing components in Borland Delphi.
 comp.lang.pascal.delphi.misc          General issues with Borland Delphi.

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
t...@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland

Other Threads