ApplicationForm.pas 994 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. unit ApplicationForm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls;
  6. type
  7. TfAppMain = class(TForm)
  8. Button1: TButton;
  9. Memo1: TMemo;
  10. procedure Button1Click(Sender: TObject);
  11. private
  12. { Private declarations }
  13. public
  14. { Public declarations }
  15. end;
  16. var
  17. fAppMain: TfAppMain;
  18. implementation
  19. {$R *.dfm}
  20. procedure TfAppMain.Button1Click(Sender: TObject);
  21. var
  22. LDLLHandle: HModule;
  23. LShowProc: TProcedure;
  24. begin
  25. LDLLHandle := LoadLibrary('TestDLL.dll');
  26. if LDLLHandle <> 0 then
  27. begin
  28. try
  29. LShowProc := GetProcAddress(LDLLHandle, 'ShowDLLForm');
  30. if Assigned(LShowProc) then
  31. begin
  32. LShowProc;
  33. end
  34. else
  35. ShowMessage('The ShowDLLForm procedure could not be found in the DLL.');
  36. finally
  37. FreeLibrary(LDLLHandle);
  38. end;
  39. end
  40. else
  41. ShowMessage('The DLL was not found. Please compile the DLL before running this application.');
  42. end;
  43. end.