By procedure pass instance of TMyConnection from main application.
When exit application, then raise Access Violation of memory error
DLL
Code: Select all
library Project2;
uses
MyAccess,
Windows,
System.SysUtils,
System.Classes;
var
Conn: TMyConnection;
{$R *.res}
procedure LS_REP_DB(Connection: TMyConnection); stdcall;
begin
Conn.AssignConnect(Connection);
end;
procedure Destroy(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
Conn.Free;
end;
exports
LS_REP_DB;
begin
Conn := TMyConnection.Create(nil);
DLLProc := @Destroy;
end.Code: Select all
type
TForm2 = class(TForm)
Button1: TButton;
MyConnection1: TMyConnection;
procedure Button1Click(Sender: TObject);
private
public
end;
procedure LS_REP_DB(Connection: TMyConnection);
stdcall external 'Project2.dll' name 'LS_REP_DB';
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
LS_REP_DB(MyConnection1);
end;Example src: http://encodable.com/cgi-bin/filechucke ... ection.zip