|
unit uMain;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type TForm1 = class(TForm) btnClose: TBitBtn; btnReport: TBitBtn; procedure btnReportClick(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.btnReportClick(Sender: TObject); var LibHandle: THandle; fDisplaySampleReport: procedure; begin LibHandle := LoadLibrary('Report.dll'); if LibHandle = 0 then raise Exception.Create('Unable to Load DLL...') else begin try @fDisplaySampleReport := GetProcAddress(LibHandle, 'DisplaySampleReport'); if @fDisplaySampleReport <> nil then fDisplaySampleReport; // Invoke the Procedure within the DLL except on E: Exception do ShowMessage('Exception error: ' + E.Message); end; end; FreeLibrary(LibHandle); // Free Memory Allocated for the DLL end;
end.
//////////////////////////////////////////////// // DLL Project
library Report;
uses SysUtils, Classes, uReport in 'uReport.pas' {Form1};
procedure DisplaySampleReport; begin Form1 := TForm1.Create(nil); try Form1.QuickRep1.Preview; finally Form1.Free; end; end;
exports DisplaySampleReport;
end.
|