Board index » delphi » vb call to delphi 2 dll help

vb call to delphi 2 dll help

i need some help with how to call a delphi dll from vb with integer and
string parameters that the dll can set. Been working on it for 2 days and
can't find documentation or get it to work by experimenting. Any help
would be appriciated.

 

Re:vb call to delphi 2 dll help


In article <01bb6b2b.d80cbda0$09fea...@idirect.com.idirect.com>, h...@idirect.com ("Keith Hambley") wrote:

Quote
>i need some help with how to call a delphi dll from vb with integer and
>string parameters that the dll can set. Been working on it for 2 days and
>can't find documentation or get it to work by experimenting. Any help
>would be appriciated.

I assume that strings are your problem.  What you need to do is use PCHARs on
the Delphi side and BYVAL x as STRING on the VB side.

John

Re:vb call to delphi 2 dll help


In article <01bb6b2b.d80cbda0$09fea...@idirect.com.idirect.com>,
h...@idirect.com says...

Quote

>i need some help with how to call a delphi dll from vb with integer and
>string parameters that the dll can set. Been working on it for 2 days and
>can't find documentation or get it to work by experimenting. Any help
>would be appriciated.

Here's the smallest VB Delphi2 DLL I have -- it just implements bit shifts in
Access Basic (same as VB).

//==>BITSHIFT.PAS
library BitShift;

uses
  BitShiftMain in 'BitShiftMain.pas';

Exports ShiftLeft, ShiftRight;

begin
end.
//
//==>BITSHIFTMAIN.PAS
unit BitShiftMain;

interface

function ShiftLeft(const V, N: Longint): Longint; stdcall;
function ShiftRight(const V, N: Longint): Longint; stdcall;

implementation

function ShiftLeft(const V, N: Longint): Longint; stdcall;
begin result := V shl N; end;

function ShiftRight(const V, N: Longint): Longint; stdcall;
begin result := V shr N; end;

end.
//
In VB, you use the following declarations:

Declare Function ShiftLeft Lib "BitShift.DLL" (ByVal V As Long, ByVal N As
Long) As Long

Declare Function ShiftRight Lib "BitShift.DLL" (ByVal V As Long, ByVal N As
Long) As Long

The most common mistake is leaving out the "stdcall" option. Also, in Win95,
keep in mind that DLL entry point names are case-sensitive.

Other Threads