Dll problem

Pete 'n' Lyn Morris petelyn at woden.com
Wed Nov 10 18:49:27 CST 1999


try
procedure DLL_EXE(var SL : TStringList);

----- Original Message -----
From: Darryl <mail at justsoft.com.au>
To: <delphi at elists.org>
Sent: Wednesday, November 10, 1999 9:05 AM
Subject: Dll problem


> Hi
>
> Im attempting to send a stringlist thats created in a DLL back to the
> calling exe, then assign that returned stringlist to a known stringlist
> in the exe, but it keeps falling over.  Ive tried a number of different
> methods with no success.  I'm a little green in this area as I've just
come
> over from vb!
>
> Any help is appreciated.
>
>
> Using sharemem in both the EXE and DLL
>
> Exe unit
>
> unit Unit1;
>
> interface
>
> ..
>
> type
>   TMySL = TStringList;
>
> procedure DLL_EXE(SL : TMySL); stdcall;
>
> type
>   ..
>
>   private
>   ..
>   public
>   ..
>   end;
>
> implementation
>
> {$R *.DFM}
>
> procedure DLL_EXE(SL : TMySL); <--- send the stringlist back here
> begin
>   ML := TStringList.create;
>   ML := SL;
>   for i := 0 to SL.count-1 do
>      showmessage(SL[i]);
> end;
>
>
> ----------
>
> DLL unit
>
>
> unit dll2exe;
>
> interface
>
> uses
>   ..
>
> procedure ShowForm(hOwner: hInst); stdcall;
>
> type
>   TMySL = TStringList;
> file://TProc = procedure(SL : TMySL); stdCall;
>
> type
>   TForm1 = class(TForm)
>     Button1: TButton;
>     procedure Button1Click(Sender: TObject);
>     procedure SL2EXE(SL : TMySL);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;
>
> var
>   Form1: TForm1;
>   ML : TMySL;
>   Str : procedure(SL : TMySL); stdcall;
>
>
> procedure TForm1.SL2EXE(SL : TMySL);
> var
> // Str: TProc;
> H : Hinst;
> begin
>   H := GetModuleHandle(Pchar('e:\array2dlls\Array2DLL.exe'));
>   try
>      @Str := GetProcAddress(H, 'DLL_EXE');
>      Str(SL);
>   except on E:Exception do
>      messagedlg(e.message, mterror,[mbOK],0);
>   end;
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   i : integer;
> begin
>   ML := TStringlist.create;
>   for i := 1 to 5 do
>      ML.add(inttostr(i*2));
> try
>      SL2EXE(ML);
>   except on E:Exception do
>      messagedlg(e.message, mterror,[mbOK],0);
> end;
> end;
>
> Mat
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at elists.org
> http://www.elists.org/mailman/listinfo/delphi
>






More information about the Delphi mailing list