Niestety na gg w pracy nie mogę ale już sam sobie postawię browara :D [browar] bo rozwiązałem problem. Za momencik wrzucę tutaj cały kod obu programów - dla potomności ;P
Treść w dll:
library Project12;
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
DB,
DBAccess,
MyAccess,
StdCtrls,
MemDS;
{$R *.res}
VAR
MyConect:TMyConnection;
Procedure conect;
Var
i:integer;
s:string;
Begin
MyConect := TMyConnection.Create(nil);
MyConect.Server:='tu_adres_bazy';
MyConect.Username:= 'user';
MyConect.Password:= 'password';
MyConect.Database:= 'jakas_baza';
MyConect.Connected:=true;
// MyConect.free;
End;
exports
conect;
begin
end.
Treść w programie który wywołuje dll:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
VAR
uchwyt:THandle;
conect:procedure;stdcall;
begin
uchwyt:= LoadLibrary('Project12.dll');
if uchwyt = 0 then
raise Exception.Create('Nie można załadować biblioteki DLL... -> etap_viewer.dll')
else
begin
try @conect:=GetProcAddress(uchwyt,'conect');
if @conect <> nil then
conect;
except
on E: Exception do
ShowMessage('Exception error: ' + E.Message);
end;
end;
FreeLibrary(uchwyt);
end;
end.
Jeżeli to się komuś przyda to ciesze się że mogłem pomóc ;)
Ps. Tobie Gothmog wirtualny browarek [browar]