Q&A

  • DLL에서 함수 호출시 발생하는 에러?
dll 를 해볼려고 아주 초간단 예제를 만들었는데
억세스 에러만 나옵니다... 도대체 이게 풀리지를 않습니다..
여기 소스가 있습니다.
진짜 초간단 입니다...
님들 도와주세요...

//////dll 소스
unit main;

interface
uses Classes, SysUtils, dialogs;
function test1(a1:pchar):boolean;
implementation

function test1(a1:pchar):boolean;
begin
  showmessage(a1);
  result:=true;
end;

///호출하는 부분
procedure TForm1.Button1Click(Sender: TObject);
type
   Ttest1 = function(a1:pchar):boolean; stdcall;
var
test1 : Ttest1;
Lib: Thandle;
a1: pchar;
begin
   Lib := LoadLibrary('dllProject2.dll');
   if (Lib < 32) then begin
      MessageDlg('cannot load library file!', mtError, [mbOk], 0);
      Exit;
   end;

   test1 := GetProcAddress(Lib, 'tes1');
   a1:='hello';  ///여기까지는 정상
   test1(a1); // 이줄만 넣으면 에러!!!!!

end;
0  COMMENTS