1. 정적 호출 방식
// 호출할 Function or Procedure 선언
function DecryptRecfile(KeyFile, sFilename : string; var ErrMsg : string) : boolean; external 'RecEncryptDLL.dll' name '
Decrypt_File';
{$R *.dfm}
procedure TForm7.Button2Click(Sender : TObject);
begin
try
var
ss : string;
if DecryptRecfile('C:\test.key', 'C:\Users\JSH\Desktop\새 폴더\암호화.wav', ss) then
Memo1.Lines.Add(format('Result : %s', [True.ToString]))
else
Memo1.Lines.Add(format('Result : %s', [ss]));
except
on E : Exception do
Memo1.Lines.Add(E.Message);
end;
end;
2. 동적 호출 방식
procedure TForm7.Button1Click(Sender : TObject);
var
hModu : integer;
test : function(KeyFile, sFilename : string; var ErrMsg : string) : boolean; // 호출할 function 내부 선언
begin
hModu := LoadLibrary('RecEncryptDLL.dll'); // dll 로드 (절대 경로 또는 exe와 함께 있으면 dll 이름만 호출)
try
try
Memo1.Lines.Add(format('handle : %d', [hModu]));
@test := GetprocAddress(hModu, 'Decrypt_File'); // test : function(KeyFile, sFilename : string; var ErrMsg : string) : boolean;
var
ss : string;
if test('C:\test.key', 'C:\Users\JSH\Desktop\새 폴더\암호화.wav', ss) then
Memo1.Lines.Add(format('Result : %s', [True.ToString]))
else
Memo1.Lines.Add(format('Result : %s', [ss]));
except
on E : Exception do
Memo1.Lines.Add(E.Message);
end;
finally
FreeLibrary(hModu);
end;
end;
'DELPHI(델파이)' 카테고리의 다른 글
[델파이 - DELPHI] HTTPS 서버 사용시 다른 포트 바인딩 주의점 (0) | 2020.11.24 |
---|---|
[델파이 - DELPHI] INDY HTTP, TCP TLS 1.2 사용 (0) | 2020.11.24 |
[델파이 - DELPHI] WINDOWS10 알림창 (0) | 2020.11.19 |
[델파이 - DELPHI] DLL 만들기 (0) | 2020.11.19 |
Window Tail (0) | 2020.03.25 |