외부 DLL에서 함수 호출(호출 표시)

1194 단어 dll
unit Unit1;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;



type

  //    ,          :

  //LoadLibrary:   DLL

  //GetProcAddress:    

  //FreeLibrary:  DLL



  //        ,           

  TMB = function(hWnd: HWND; lpText, lpCaption: PChar; uType: UINT): Integer; stdcall;



  TForm1 = class(TForm)

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);

  private

    MB: TMB;  {     MB}

    inst: LongWord;  {              DLL   }

  public

    { Public declarations }

  end;



var

  Form1: TForm1;



implementation



{$R *.dfm}



procedure TForm1.FormCreate(Sender: TObject);

begin

  inst := LoadLibrary('user32.dll');

  if inst <> 0 then

    MB := GetProcAddress(inst, 'MessageBoxW');

end;



//    :

procedure TForm1.Button1Click(Sender: TObject);

var

  t,b: PChar;

begin

  t := '  ';

  b := '  ';

  MB(0, b, t, 0);

end;



procedure TForm1.FormDestroy(Sender: TObject);

begin

  FreeLibrary(inst);  {    }

end;



end.

좋은 웹페이지 즐겨찾기