델파이로 표준 C 방식의 dll을 만들어서 다른 프로그램에서 사용하려고 합니다.
dll에서 정의된 함수 호출시 함수의 인자를 PChar로 넘길려고 하는데요. 잘 안되네요.
PChar를 인자로 주고 PChar로 결과를 받는 방법은 무엇인가요?
---------------호출 프로그램 ---------------------------
function MyReplace(luDate: PChar): PChar; external 'MyDLL.dll';
procedure TForm1.Button1Click(Sender: TObject);
var
rtn: string;
aPChar: PChar;
begin
aPChar := PChar('1990-09-19');
aPChar := MyReplace(aPChar);
rtn := StrPas(aPChar);
ShowMessage(rtn);
end;
-----------------dll 프로그램(MyDLL.dll) ------------------------
library MyDLL;
uses
SysUtils, Classes;
{$R *.res}
function MyReplace(luDate: PChar): PChar; cdecl;
var
TmpStr: String;
luYear, luMonth, luDay: Integer;
begin
TmpStr:= StrPas(luDate);
TmpStr := StringReplace( TmpStr, '-', '', [rfReplaceAll] );
luYear := StrToInt(copy(TmpStr,1,4));
luMonth := StrToInt(copy(TmpStr,5,2));
luDay := StrToInt(copy(TmpStr,7,2));
TmpStr:= Format('%s-%s-%s'#0, [IntToStr(luYear), IntToStr(luMonth), IntToStr(luoDay)]);
Result := PChar(TmpStr);
end;
exports MyReplace;
begin
end.
------------------------------------------------------------
관심 가져주셔서 감사합니다.
|