Untitled

 avatar
unknown
pascal
a year ago
958 B
19
Indexable
// Test DLL w uzyciu
// Kornelia S.

program usedlltest;

{$R *.res}

uses
  Winapi.Windows,
  System.SysUtils,
  Vcl.Dialogs;        // jedynie dla ShowMessage

type
  TMyFunction = function: Integer; stdcall;

var
  DLLHandle: THandle;
  MyFunction: TMyFunction;

begin
  try
    DLLHandle := LoadLibrary('MyLibrary.dll');
    try
      if DLLHandle <> 0 then begin
        @MyFunction := GetProcAddress(DLLHandle, 'MyFunction');
        if Assigned(MyFunction) then
        begin
          // DLL i funkcja są dostępne i używane
          ShowMessage('DLL jest używana!');
        end
        else begin
          ShowMessage('Nie można załadować funkcji z DLL.');
        end;
      end else begin
        ShowMessage('Nie można załadować DLL.');
      end;
    finally
      FreeLibrary(DLLHandle);
    end;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
Editor is loading...
Leave a Comment