whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

66 Visitors Online


 
...Call Procedures within a DLL?
Autor: Michael Casse
[ Print tip ]  

Tip Rating (9):  
     


//  Call DLL Program  (Normal Application Project)
//  This example calls a Quick Report within a DLL.
//  Author: Michael Casse.
//  18-12-2001.

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.



 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners