본문 바로가기

컴터/delphi

동적 dll 링크

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var   ////동적 dll 만들기..
    iDllHandle : Integer;
    DllFunc : Function (a, b : Integer): Integer;  //해당 함수 레퍼런스 가지고 있게.
begin
  iDllHandle := LoadLibrary('dll1.dll');  //dll 파일 호출
  if iDllHandle >= 32 then begin ////32미만은 에러다.메모리에 올리기.
    @DllFunc := GetProcAddress(iDllHandle, 'Sum');//@는포인터로 바꿈

    if @DllFunc <> Nil then
      ShowMessage(IntToStr(DllFunc(1, 2)));

    FreeLibrary(iDllHandle);////dll 메모리 해제
  end;

end;