
Need HELP with Delphi DLL to be Called by VB 5.0
Does Delphi have a utility to list DLL exports? I know
Borland C++ does. I'd make sure the name is being exported
exaclty as defined.
Also, *never* return double.
If you check the Windows APIs, none of them return
double or float. There is no standard defined by Microsoft
for returning floats or doubles from DLLs, so (of course),
Microsoft does it one way, Borland does it another.
This guarantees you won't be able to call your DLL from
a Microsoft language.
You can pass in the double as a ByRef argument to
get back your result. Alternatively, you could return
an OLE_VARIANT containing the double.
--
Ron Ruble
Raffles Software Development, Inc.
Quote:
>I am trying to develop a DLL in Delphi 2.0 that I can call from Visual
>Basic 5.0. I can successfully call the DLL from Delphi, but when I try
>to call it from VB 5.0 I get an error message that "the function TSAT
>does not exist in the file PSATDLL1". A simplified example is shown
>below. I appreciate any help that can be sent my way on this one.
>Has anyone had success in doing this?
>***************************
>The Delphi 2.0 DLL starts here.
>***************************
>{f+}
>library dll10;
>uses
> windows,
> stdctrls,
> FUNCTION TSAT(P_X: double):double; far; export; stdcall;
> BEGIN
> TSAT := 2*P_X;
> END;
> exports
>BEGIN
>END.
>*************************************
>The VB 5.0 Calling Program starts here.
>***********************************
>Option Explicit
>Private Declare Function TSAT Lib "PSATDLL1.dll" (ByVal PX As Double) As
>Double
>Private Sub Command1_Click()
>Dim TX, PX As Double
>PX = 20.0
>TX = TSAT(TX)
>End Sub