Q&A

  • VB에서 사용하던 dll을 delphi에서 사용하려고 합니다.
아래의 소스와 같이 VB에서 사용하던 dll을 사용하기 위해서 Delphi로 수정했습니다.
그런데 @funGetOS가 항상 널값을 반환합니다.
주석으로 처리된 dll을 이용하면 제대로 실행이 됩니다.
VB에서 사용하던 dll을 델파이에서 사용하려면 어떻게 하면 될까요?

<!--CodeS-->
<<VB>>
Set KitrusObj = CreateObject("KRSMSV.KitrusObject")
clientIP = KitrusObj.GetClientIP

<<Delphi>>
procedure TForm1.Button1Click(Sender: TObject);
type
  TDllFunc = Function() : integer ; stdcall;

var
  strDllFile: String;
  hdlDllKitrus: THandle;
  funGetOS : TDllFunc;

begin
  strDllFile := 'Krsmsv.dll';
//  strDllFile := 'I:\Krs-Trial\bass23\bass.dll';

  if not FileExists(strDllFile) then
  begin
    Showmessage('파일없음');
    Abort;
  end;
  hdlDllKitrus := LoadLibrary(PChar(strDllFile));
  if hdlDllKitrus < 32 Then
  begin
    Showmessage('실행실패');
    Abort;
  end;

  try
    @funGetOS := GetProcAddress(hdlDllKitrus,'GetClientOS');
//    @funGetOS := GetProcAddress(hdlDllKitrus,'BASS_GetDevice');

    if not (@funGetOS = nil ) then
    begin
      Edit1.Text := funGetOS;
    end
    else
    begin
      ShowMessage('ErrNo:' + IntToStr(GetLastError));
    end;
  finally
     FreeLibrary(hdlDllKitrus);
  end;
end;
<!--CodeE-->
0  COMMENTS