was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

66 Visitors Online


 
...Funktionen aus einer DLL ausführen?
Autor: Michael Casse
[ Tip ausdrucken ]  

Tip Bewertung (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.



 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


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