delphi调用c++ dll参数char* 的问题

我有一个c作的dll 具体说明如下
1、文件解密接口函数及参数说明:
int stdcall DecodeFile(char* InFile, //要解密的文件

char* Key, //解密的密钥

char* OutFile, //解密后的文件,在解密路径下的同名XML文件

char* Info);

//提示信息函数返回 0 成功,非0失败。
2、动态调用实例:

String jmfile = 要解密的文件路径;

String key = 要解密的文件密钥;
String strDllFile = "DecodeXMLFIle.dll"; //解密动态库文件名

DLLInst = LoadLibrary(strDllFile.c_str());

if( !DLLInst)

Application->MessageBox( "DLL装载错误", "错误信息", MB_ICONERROR); else

{ /l输入函数声明 int (
stdcall DecodeFile)(char InFile,

char* Key,

char* OutFile,

char* Info);

DecodeFile = (int (__stdcall )(char InFile,

char* Key,

char* OutFile,

char* Info))GetProcAddress( DLLInst, "DecodeFile");

if (DecodeFile)

{

char outfilestr[1000] = {0};

char msgInfostr[1000] = {0};

int dRes = DecodeFile(jmfile.c_str(),key.c_str(),outfilestr,msgInfostr); if(dRes != 0)

{

String Msgstr = "提示信息:解密失败 "+AnsiString(msgInfostr);
Application->MessageBox(Msgstr, "错误信息", MB_ICONERROR);

}else

Application->MessageBox("成功", "成功", MB_OK);

}

}

FreeLibrary(DLLInst);

如何用delph声明这个函数并调用呢

用pchar类型,dll如何声明使用,网上搜搜吧

不知道为什么 我用了pchar不行呀
FreeLibrary(dll);
还报内存错

dllinst是否为正确句柄,不然释放会有问题。

看下是不是unicode的字符串?用byte是什么?

function DecodeFile(InFile: PAnsichar;Key: PAnsichar;OutFile: PAnsichar;Info: PAnsichar): integer;stdcall;

C++的char*一般都是PAnsichar
W_Char*才是双字节PWideChar
另外Pchar在2007之后对应的是PWideChar

这个有unsign char/char /等等的区别,DES加密解密的使用很多

char*如果你使用delphi2010前的版本是Pchar,以后的版本用PAnsiChar,因为是Unicode编码