나는 이제 우리는 델파이 2007 에서 우리는 DLL에 대한 C의 ++ 헤더를 가지고 사용하고자하는 등 트럭Delphi에서 "_pascal calling convention"을 사용하여 dll을 호출하는 방법은 무엇입니까?
을 계획하는 데 사용되는 라우팅 프로그램 RouteLogix에서 dll을 RL6_dll.dll 및 작업 예제가 그 C++에서 사용 - Builder. 델파이에서
// Use this routine to find the directory where the data-xxx subdirectories
// are expected.
// char * vszBuf - address of a character array to receive the (null-terminated) path.
// int nBufSize - is the size of the array
// (internally we allow paths up to 256 characters long)
DllFn(void) RL6_GetLocalGeoDir(char *vszBuf, int nBufSize);
내 시도 :
procedure TfrmRL6Xml.Button1Click(Sender: TObject);
var
s1: PChar;
IntValue : Integer;
RL6_GetLocalGeoDir: function(vszBuf: pchar; nBufSize: Integer): integer; stdcall;
begin
handle := LoadLibrary('C:\Carp\RL6_app2\rl6dll\RL6_DLL.dll');
if handle <> 0 then
begin
@DllFn := GetProcAddress(handle, 'RL6_PREINIT');
@RL6_GetLocalGeoDir := GetProcAddress(handle, 'RL6_GETLOCALGEODIR');
s1 := ' ';
IntValue := length (s1);
RL6_GetLocalGeoDir (s1, IntValue);
showMessage(s1);
end;
end;
그래서 지금은 S1이 문자열을 포함하는 기대, 대신 기능을 문자열로있는 intValue을 처리 할 것 같다 여기
해당 파일의 예입니다. s1과 IntValue 매개 변수가 교환 된 것처럼 보입니다. 우리는 물론 RL6_GetLocalGeoDir (IntValue, s1)을 시도했지만 그 중 하나도 작동하지 않았습니다. 그것을 부르는 어떤 제안?
나는이 예제를 너무 단순화했습니다. 예제가 바로 수정되었습니다. –
나는 그것이 수정되었다고 생각지 않는다, 왜 당신은'PChar'에'Length()'를 부를까요? – mghie
C에서 "char"은 1 바이트 char이기 때문에 PAnsiChar와 AnsiString을 더 좋게 만듭니다. –