FastReport_2022_VCL/Demos/Dll/TestDLL.pas
2024-01-01 16:13:08 +01:00

66 lines
1.4 KiB
ObjectPascal

unit TestDLL;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, frxGDIPAPI;
type
TShowForm = function(H: THandle): Bool; StdCall;
EDLLLoadError = class(Exception);
TfrmCallDLL = class(TForm)
btnCallDLL: TButton;
btnClose: TButton;
procedure btnCallDLLClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
end;
var
frmCallDLL: TfrmCallDLL;
implementation
{$R *.DFM}
procedure TfrmCallDLL.btnCallDLLClick(Sender: TObject);
var
LibHandle: THandle;
ShowForm: TShowForm;
StartupInput: TGDIPlusStartupInput;
gdiplusToken: ULONG;
begin
LibHandle := LoadLibrary('RptDLL.DLL');
try
if LibHandle = HINSTANCE_ERROR then
raise EDLLLoadError.Create('Unable to Load DLL');
@ShowForm := GetProcAddress(LibHandle, 'ShowForm');
if not (@ShowForm = nil) then
try
// Initialize StartupInput structure
StartupInput.DebugEventCallback := nil;
StartupInput.SuppressBackgroundThread := False;
StartupInput.SuppressExternalCodecs := False;
StartupInput.GdiplusVersion := 1;
// Initialize GDI+
GdiplusStartup(gdiplusToken, @StartupInput, nil);
ShowForm(Application.Handle);
finally
GdiplusShutdown(gdiplusToken);
end;
finally
FreeLibrary(LibHandle);
end;
end;
procedure TfrmCallDLL.btnCloseClick(Sender: TObject);
begin
Close;
end;
end.