<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Normale Seite ohne Titel</title>
</head>
<body bgcolor="#FFFFFF">
<p>Hi,<p> ich möchte eine Funktion in eine DLL auslagern. Bei der
praktischen Umsetzung habe ich allerdings massive Probleme.
Bereits die Übergabe des Strings an die DLL-Funktion
funktioniert nicht. Was mahce ich falsch? </p>
<p>Einen stark vereinfachten Quellcode für die DLL und den
Zugriff auf die DLL habe ich beigefügt. </p>
<pre><font color="#0080C0"><strong>library test;
uses
sharemem, sysutils;
function string_test(s: PChar): PChar; stdcall;
begin
result := s;
end;
exports
string_test index 1;
begin
end.</strong></font></pre>
<p> </p>
<pre><font color="#FF0000"><strong>unit Unit1;
interface
uses
sharemem, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
s1: pchar;
function string_test(s: pchar): pchar; stdcall;
implementation
{$R *.DFM}
function string_test; stdcall; external 'd:\test.dll' index 1;
procedure TForm1.Button1Click(Sender: TObject);
begin
s1:= string_test(' Test');
end;
end.</strong></font></pre>
<p> </p>
<p>Vielen Dank im voraus.</p>
<p> </p>
<p>Tschüß</p>
<p>Torsten</p>
</body>
</html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Normale Seite ohne Titel</title>
</head>
<body bgcolor="#FFFFFF">
<p>Hi,<p> ich möchte eine Funktion in eine DLL auslagern. Bei der
praktischen Umsetzung habe ich allerdings massive Probleme.
Bereits die Übergabe des Strings an die DLL-Funktion
funktioniert nicht. Was mahce ich falsch? </p>
<p>Einen stark vereinfachten Quellcode für die DLL und den
Zugriff auf die DLL habe ich beigefügt. </p>
<pre><font color="#0080C0"><strong>library test;
uses
sharemem, sysutils;
function string_test(s: PChar): PChar; stdcall;
begin
result := s;
end;
exports
string_test index 1;
begin
end.</strong></font></pre>
<p> </p>
<pre><font color="#FF0000"><strong>unit Unit1;
interface
uses
sharemem, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
s1: pchar;
function string_test(s: pchar): pchar; stdcall;
implementation
{$R *.DFM}
function string_test; stdcall; external 'd:\test.dll' index 1;
procedure TForm1.Button1Click(Sender: TObject);
begin
s1:= string_test(' Test');
end;
end.</strong></font></pre>
<p> </p>
<p>Vielen Dank im voraus.</p>
<p> </p>
<p>Tschüß</p>
<p>Torsten</p>
</body>
</html>
Comment