안녕하십니까 ?
외부 C로 만든 DLL 을 호출하는데 GetProcAddress를 호출하면 NIL 값이 계속나오는데
코딩이 잘못 됐는지 고수님들의 답변을 부탁합니다.....
unit alphaComm;
interface
uses
STDCTRLS, SYSUTILS, FORMS, DBCTRLS, GRAPHICS, Messages, Dialogs,
DBTABLES, QRCTRLS, MASK, WINDOWS, GRIDS, Classes, Controls,
ComCtrls, DBGrids, ExtCtrls, Db;
type
TKpc_TcpSeCureInstallReQuest=function(szID,szPasswd:pchar;szResCode:pchar; hwandReceiveMessage:HWND):integer; stdCall;
TKpc_sendReQuest=function(SendData,RecvData:pchar;hwandReceiveMessage:HWND ):integer; stdCall;
EDLLLoadError=class(Exception);
function KmpsApproval(
SendData : string;
RecvData : string;
MSG : string): string; EXPORT;
implementation
{===============================================================================}
function KmpsApproval(SendData:string; RecvData:string;MSG:string):string; EXPORT;
{===============================================================================}
var
Kpc_TcpSeCureInstallReQuest :TKpc_TcpSeCureInstallReQuest;
Kpc_sendReQuest :TKpc_sendReQuest;
Libhandle : THandle;
SendDat : array[0..176] of char;
RecvDat : array[0..1023] of char;
szID : array[0..3] of char;
szPasswd : array[0..15] of char;
szResCode: array[0..4] of char;
SendHWND : HWND;
lID,lPWD :string;
tmp : string;
i : word;
j : integer;
begin
LibHandle :=LoadLibrary('kmpspos20.dll');
if LibHandle = 0 then
begin
raise EDLLLoadError.Create('kmpspos20.DLL을 로드할수 없습니다.');
ShowMessage('kmpspos20.DLL을 로드할수 없습니다..');
end;
lid:='kap';
lPwd:='rmj8813';
StrCopy(szID ,PChar(lID));
StrCopy(szPasswd,PChar(lPWD));
for i := 0 to 3 do
begin
szResCode[i]:=' ';
end;
@Kpc_TcpSeCureInstallReQuest:=GetProcAddress(LibHandle,'Kpc_TcpSeCureInstallReQuest'); //메모리주소 참조 ???????????
if (@Kpc_TcpSeCureInstallReQuest) = Nil then
if Kpc_TcpSeCureInstallReQuest(szID,szPasswd,szResCode,SendHWND) <> 0 then
ShowMessage('초기 인스톨 작업을 실패했습니다..');
tmp:='';
for i := 0 to 3 do
begin
if szResCode[i]<> #0 then
tmp:=tmp+szResCode[i]
else
break;
end;
if Tmp='0000' then ShowMessage('설치완료.')
else if Tmp='8001' then ShowMessage('미등록 ID오류')
else if Tmp='8002' then ShowMessage('패스워드 오류')
else if Tmp='8003' then ShowMessage('MAC주소중복오류')
else ShowMessage('기타오류');
FreeLibrary(LibHandle);
end;
end.