DELPHI调用VC的DLL函数参数LPTSTR 问题解决了,进来就送分
在VC中编写DLL的代码
extern "C" __declspec(dllexport) LPTSTR WINAPI Do(LPTSTR i)
{
return i;
}
在DELPHI中调用
type
TPCharFunc=function(i:PChar):PChar;stdcall;
var
Th:Thandle;
Tc:TPCharFunc;
Tp:TFarProc;
str:PChar;
strA:PChar;
begin
Th:=LoadLibrary('abc.dll'); {装载DLL}
if Th>0 then
try
Tp:=GetProcAddress(Th,PChar('_Do@4'));
if Tp<>nil
then begin
Tc:=TPCharFunc(Tp);
ShowMessage(Tc('break'));
//ShowMessage('找到函数');
end
else
ShowMessage('没有找到函数');
finally
FreeLibrary(Th); {释放DLL}
end
else
ShowMessage('dll文件没找到');
end;
用这样调用的话,传进去是break传出来是乱码,大家帮我看看
我自己解决了,进来的就送分啊,要用PWideChar传进去而不是用PChar传,(*^__^*) 嘻嘻