Board index » delphi » Calling a Delphi DLL in VB passing strings

Calling a Delphi DLL in VB passing strings

I intent to call a DLL (MAYUSCUL) from a Visual Basic 4.0 Code passing
Strings between VB and Delphi but I can'not do this. Anybody knows
the solution?

I will be very gratefully when somebody helps.

Hans Lazzaro
e-mail :Hlazz...@blgate.cl

----------------------------------------------------------
My Delphi code for the DLL:

unit Mayus1;

interface

function Mayus(Valor:String):PChar; export;

implementation

uses SysUtils, Wintypes, WinProcs, Forms, IniFiles, Dialogs;

function Mayus(Valor:String):PChar;
var
   PointerChar: PChar;
   ArrayOfChar: Array [0..1024] of Char;
begin
   PointerChar := ArrayOfChar;
   StrPCopy(PointerChar, UpperCase(Valor));
   Mayus := PointerChar;
end;

end.

----------------------------------------------------------
My VB code calling the DLL:

Declare Function Mayus Lib "MAYUSCUL" (ByVal Valor As String) As String

------------------------------------------------------------------------

 

Re:Calling a Delphi DLL in VB passing strings


Quote
Hans Lazzaro <hlazz...@blgate.cl> wrote:
>I intent to call a DLL (MAYUSCUL) from a Visual Basic 4.0 Code passing
>Strings between VB and Delphi but I can'not do this. Anybody knows
>the solution?
>I will be very gratefully when somebody helps.
>Hans Lazzaro
>e-mail :Hlazz...@blgate.cl
>----------------------------------------------------------
>My Delphi code for the DLL:
>unit Mayus1;
>interface
>function Mayus(Valor:String):PChar; export;
>implementation
>uses SysUtils, Wintypes, WinProcs, Forms, IniFiles, Dialogs;
>function Mayus(Valor:String):PChar;
>var
>   PointerChar: PChar;
>   ArrayOfChar: Array [0..1024] of Char;
>begin
>   PointerChar := ArrayOfChar;
>   StrPCopy(PointerChar, UpperCase(Valor));
>   Mayus := PointerChar;
>end;
>end.
>----------------------------------------------------------
>My VB code calling the DLL:
>Declare Function Mayus Lib "MAYUSCUL" (ByVal Valor As String) As String
>------------------------------------------------------------------------

The following works with VB3 and Delphi 1.  It should be the same for
VB4.

In VB4

Declare Function ShowString Lib "YourDLL.dll" (ByVal s As String) As
Integer

In Delphi

function ShowString(p: PChar): Boolean; export;
var
    S: String;
    DBPath: String;
    ini: TIniFile;
begin
    S := StrPas(p);
    MessageDlg(S, mtWarning, [mbOk], 0);
end;

exports
   ShowString index 1;

E-Mail me if you need more info

Kev

Other Threads