안녕하세요
프로그램베이에서 프로그램 등록용 dll 및 소스 파일을 제공하고 있는데
델파일7과 vc, vb용밖에 없습니다. 그래서
프로젝트에 upbcon.pas를 추가한 다음 컴파일을 하면 Unresolved external '_PBLogin@8' referenced from ...\upbcon.obj 등의 오류가 발생합니다.
(해당 자료는 여기 있습니다 :
http://www.programbay.co.kr/upload/module/manual.zip)
upbcon.pas 소스는 다음과 같습니다
unit Upbcon;
interface
uses
Windows, Messages, IdHTTP, ExtCtrls;
type
my_Timer = class(TTimer)
//pb_Timer : TTimer;
private
procedure pbcon_Timer(Sender: TObject);
end;
function PbLogin(progid, title : pchar): Boolean; stdcall; external 'pbcon.dll' name '_PbLogin@8';
function PbAutoLogin(progid, title : pchar; autologin : Integer): Boolean; stdcall; external 'pbcon.dll' name '_PbLogin_AutoLogin@12';
function closeCB(func : Pointer) : Integer; stdcall; external 'pbcon.dll' name '_CloseCB@4';
function UnloadDLL: Integer; stdcall; external 'pbcon.dll' name 'Dll_Unload';
function GetLoginID(id : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetLoginID@4';
function isFreeUser: Integer; stdcall; external 'pbcon.dll' name 'isFreeUser';
function isAutoLogin: Integer; stdcall; external 'pbcon.dll' name 'isAutoLogin';
function SetAutoLogin(val : Integer) : Integer; stdcall; external 'pbcon.dll' name '_SetAutoLogin@4';
function GetEncCode(pdec : PChar; penc : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetENCCode@8';
function GetOption(opt : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetOption@4';
function pbcon_Login (progid, title: pchar; autologin: Integer): Boolean;
function pbcon_GetLoginID() : string;
function pbcon_isFreeUser() : Integer;
function pbcon_isAutoLogin() : Integer;
function pbcon_SetAutoLogin(val : Integer) : Integer;
function pbcon_GetEncCode(pdec : string) : string;
function pbcon_RndString: String;
function pbcon_CheckAuth(var pDec: string; var pEnc: string): Boolean;
function pbcon_GetOption() : string;
procedure pbcon_SetMainWnd(pHandle : Hwnd);
procedure pbcon_ProjectEnd();
procedure pbcon_Init();
procedure pbcon_Unload();
procedure KillProcess(hWindowHandle: HWND);
//procedure pbcon_Timer(Sender: TObject);
var
pb_MainFormHwnd : Hwnd;
pb_isUnloadfromDLL : Boolean;
pb_MsgAutoLogin : array[0..3] of string;
pb_MsgIsAutoLogin : array[0..1] of string;
pb_MsgIsFreeUser : array[0..1] of string;
pb_Timer : my_Timer;
implementation
procedure pbcon_Init();
begin
pb_MsgAutoLogin[0] := '자동로그인 설정을 변경했습니다.';
pb_MsgAutoLogin[1] := '로그인시 비밀번호를 저장하지 않으면 자동로그인의 설정을 변경할 수 없습니다.';
pb_MsgAutoLogin[2] := '접속모듈을 추가할때 자동로그인 기능을 사용하도록 설정하셔야 합니다. (메뉴얼참고)';
pb_MsgAutoLogin[3] := '알수없는 오류로 자동로그인 설정에 실패했습니다.';
pb_MsgIsAutoLogin[0] := '자동로그인 사용';
pb_MsgIsAutoLogin[1] := '자동로그인 비사용';
pb_MsgIsFreeUser[0] := '정식 사용자';
pb_MsgIsFreeUser[1] := '체험판 사용자';
end;
function pbcon_Login(progid, title: pchar; autologin: Integer): Boolean;
var
bResult1, bResult2 : Boolean;
lpDec, lpEnc : string;
begin
pbcon_Init();
pb_isUnloadfromDLL := False;
if autologin = 0 then
bResult1 := PbLogin(progid, title)
else
bResult1 := PbAutoLogin(progid, title, 1);
bResult2 := False;
if bResult1 then
begin
lpDec := PChar(pbcon_RndString);
lpEnc := pbcon_GetEncCode(lpDec);
bResult2 := pbcon_CheckAuth(lpDec, lpEnc);
end;
if bResult1 and bResult2 then
closeCB(@pbcon_ProjectEnd);
Result := bResult1 and bResult2;
end;
procedure pbcon_SetMainWnd(pHandle : Hwnd);
begin
pb_MainFormHwnd := pHandle;
end;
procedure pbcon_ProjectEnd();
begin
pb_isUnloadfromDLL := True;
pb_Timer := my_Timer.Create( nil );
pb_Timer.OnTimer := pb_Timer.pbcon_Timer;
pb_Timer.Enabled := False;
pb_Timer.Interval := 1000;
pb_Timer.Enabled := True;
end;
function pbcon_GetLoginID() : string;
var
loginID : string;
bid : array[0..24] of char;
begin
GetLoginID(@bid[0]);
loginID := bid;
Result := loginID;
end;
function pbcon_isFreeUser() : Integer;
begin
Result := isFreeUser;
end;
function pbcon_isAutoLogin() : Integer;
begin
Result := isAutoLogin;
end;
function pbcon_GetOption() : string;
var
lpOpt : string;
bopt : array[0..24] of char;
begin
GetOption(@bopt[0]);
lpOpt := bopt;
Result := lpOpt;
end;
function pbcon_SetAutoLogin(val : Integer) : Integer;
begin
Result := SetAutoLogin(val);
end;
function pbcon_GetEncCode(pdec : string) : string;
var
benc : array[0..2000] of char;
begin
GetEncCode(PChar(pDec), @benc[0]);
Result := benc;
end;
function pbcon_RndString: String;
function RndChar: Char;
begin
Result := Char( Random(Ord('Z') - Ord('A') + 1) + Ord('A') );
end;
var
i : Integer;
begin
Result := '';
for i:=0 to Random(5)+5 do
Result := Result + RndChar
end;
function pbcon_CheckAuth(var pDec: string; var pEnc: string): Boolean;
var
txt : string;
IdHTTP1 : TIdHTTP;
lpURL : string;
lpResult : Boolean;
begin
Result := False;
try
IdHTTP1 := TIdHTTP.Create(nil);
try
lpURL := '
http://121.125.71.199/Auth/AuthQuery.pb';
lpURL := lpURL + '?dec=' + pDec;
lpURL := lpURL + '&enc=' + pEnc;
IdHTTP1.Port := 80;
txt := IdHTTP1.Get(lpURL);
if txt = 'True' then
lpResult := True
else
lpResult := False
finally
IdHTTP1.Free;
end;
Result := lpResult;
except
Exit;
end;
end;
procedure pbcon_Unload();
begin
if pb_isUnloadfromDLL = False then
UnloadDLL();
end;
procedure KillProcess(hWindowHandle: HWND);
var
hprocessID: INTEGER;
processHandle: THandle;
DWResult: DWORD;
begin
SendMessageTimeout(hWindowHandle, WM_CLOSE, 0, 0,
SMTO_ABORTIFHUNG or SMTO_NORMAL, 5000, DWResult);
if isWindow(hWindowHandle) then
begin
// PostMessage(hWindowHandle, WM_QUIT, 0, 0);
{ Get the process identifier for the window}
GetWindowThreadProcessID(hWindowHandle, @hprocessID);
if hprocessID <> 0 then
begin
{ Get the process handle }
processHandle := OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,
False, hprocessID);
if processHandle <> 0 then
begin
{ Terminate the process }
TerminateProcess(processHandle, 0);
CloseHandle(ProcessHandle);
end;
end;
end;
end;
procedure my_Timer.pbcon_Timer(Sender: TObject);
begin
pb_Timer.Enabled := False;
PostMessage(pb_MainFormHwnd, WM_QUIT, 0, 0);
end;
end.
여기서
function PbLogin(progid, title : pchar): Boolean; stdcall; external 'pbcon.dll' name '_PbLogin@8';
function PbAutoLogin(progid, title : pchar; autologin : Integer): Boolean; stdcall; external 'pbcon.dll' name '_PbLogin_AutoLogin@12';
function closeCB(func : Pointer) : Integer; stdcall; external 'pbcon.dll' name '_CloseCB@4';
function UnloadDLL: Integer; stdcall; external 'pbcon.dll' name 'Dll_Unload';
function GetLoginID(id : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetLoginID@4';
function isFreeUser: Integer; stdcall; external 'pbcon.dll' name 'isFreeUser';
function isAutoLogin: Integer; stdcall; external 'pbcon.dll' name 'isAutoLogin';
function SetAutoLogin(val : Integer) : Integer; stdcall; external 'pbcon.dll' name '_SetAutoLogin@4';
function GetEncCode(pdec : PChar; penc : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetENCCode@8';
function GetOption(opt : Pointer): Integer; stdcall; external 'pbcon.dll' name '_GetOption@4';
이 부분에서 오류가 발생하는 것 같습니다 그래서
implib pbcon.lib pbcon.dll을 통해 lib를 만들어 라이브러리를 추가한 후 해봐도 마찬가지입니다..
stdcall을 cdecl 등으로 바꿔도 마찬가지구요..
dll 파일 또한 라이브러리 및 include 경로에 모두 포함되어 있습니다.
어떻게 해결해야 하나요? 고수님들 도와주시면 감사하겠습니다 ㅠ