DELPHI2007和2009再PChar上的不同(100)

rocketking

New Member
Member
#1
我用c++buider建立了一个DLL程序,其声明如下:extern "C" declspec(__dllexport) __stdcall void CDLL(int a, int b, int& c ,char* s0, char *s1){ *c=a*b;
s1=strcpy(s1," Hi ! ");
s1=strcat(s1,s0);}这个DLL文件再C++Builder和Delphi2007下都可顺利被调用,结果也正确。但再Delphi2009更好调用完后,各参量基本都对,但就是返回的s1不对,中间还有乱码,不知为什么?Delphi中声明如下:procedure CDLL(integer a,b;
var c:integer;
PChar s0;
PChar s1);far;stdcall;external 'CDLL';经过测试D2007和D2009的char类型长度有了变化(由1变成了2),但PChar用得是AnsiChar却没有变化,上面的问题症结究竟何在?
 

tseug

New Member
Member
#4
没用过D2k7,D2k9,难道Delphi的语法都支持这样声明了?procedure CDLL(integer a,b;
var c:integer;
PChar s0;
PChar s1);far;stdcall;external 'CDLL';
 

wr960204

New Member
Member
#5
D2009以前:Char=ansichar;PChar = ^char;D2009:Char=WideChar;PChar = ^Char;你的旧程序声明可以转为procedure CDLL(integer a,b;
var c:integer;
s0 , S1 : PAnsiChar);far;stdcall;external 'CDLL';