1
由於我已經從delphi 5升級到XE,我正努力使用前面編譯的特定Dll。我的堵點似乎與爲Unicode/ANSI字符,但我還沒有找到如何解決這個問題使用delphiXE的pchar參數調用delphi 2006 dll
下面是過程的例子:
procedure GetFilename(Buffer: PChar; BufSize: Integer); stdcall;
在我的代碼我打電話這一點,方式
implementation
procedure GetFilename; external 'myDll.dll' name 'GetFilename';
procedure myproc
var
buffer : Array [0..255] of Char;
begin
GetFilename(buffer, length(buffer)-1);
Showmessage(buffer); //This gives me chinese character
end;
緩衝區包含此:
byte((@buffer[0])^); // 67 which is the ASCII for C
byte((@buffer[1])^); // 92 which is the ASCII for \
什麼我期待正常是海峽ing「C:\」
有沒有人遇到同樣的問題?
無需在實現部分中更改'GetFilename'的'external'聲明。只有接口部分的聲明必須從'PChar'更改爲'PAnsiChar'。 –