50分求助。Delphi代码类型如下:
Tdll = function(fid:Integer; ostr : PChar; out tests : WideString):Integer;cdecl;
定义一些变量如下:
re : Integer;
Td : Tdll;
mystr : array[1..20] of char;
ss : WideString;
初始化如下:
ss:='input for test';
调用方式如下:
re := Td(8888, @mystr[1], ss);VC DLL接口:
__declspec(dllexport) int Td(int iFunction, char *ostr, BSTR ss);
函数内容:
__declspec(dllexport) int Td(int iFunction, char *ostr, BSTR ss)
{
strcpy(ostr,"111111111");
ss = CComBSTR("This is a test");
return 1;
}结果:函数调用没问题,函数返回值没问题,参数中的ostr : PChar参数能返回,但是WideString死活返回不了!!!,请大家帮忙。
WideString
Tdll = function(fid:Integer; ostr : PChar; out tests : WideString):Integer;cdecl;
定义一些变量如下:
re : Integer;
Td : Tdll;
mystr : array[1..20] of char;
ss : WideString;
初始化如下:
ss:='input for test';
调用方式如下:
re := Td(8888, @mystr[1], ss);VC DLL接口:
__declspec(dllexport) int Td(int iFunction, char *ostr, BSTR ss);
函数内容:
__declspec(dllexport) int Td(int iFunction, char *ostr, BSTR ss)
{
strcpy(ostr,"111111111");
ss = CComBSTR("This is a test");
return 1;
}结果:函数调用没问题,函数返回值没问题,参数中的ostr : PChar参数能返回,但是WideString死活返回不了!!!,请大家帮忙。
WideString
//使用PWideChar代替
//可能是这样 Tdll = function(fid: Integer; ostr: PChar; ss: PWideChar): Integer; cdecl; mystr : array[1..20] of char;
ss: PWideChar;re := Td(8888, @mystr[1], ss);