主题:在Delphi中怎样调用C语言创建的Dll文件中的函数。
各位朋友,你们好!
本人想用Delphi调用一个Dll文件中的函数 int initREAC(char ** host_list)。
下边是函数调用的说明
// 返回值:0 - 成功, -1 - 失败
// 参数:host_list - 通讯主机列表,如:{"192.168.0.20", "192.168.0.21", ""}
// 说明:如果host_list 为NULL,则自动到动态库所在的目录下找host.lst文件获取主机列表
// host.lst格式为:
/*
192.168.0.20
192.168.0.21
*/
这里是该Dll文件的调用例子
int ret;
char * host_list[3] = {"192.168.0.2", "192.168.0.3", ""};
ret = initREAC(host_list);
我对C语言了解的有限,请各位帮忙提供一段Delphi的转换代码。谢谢!!
下边是我写的一段程序,总是有错误
type
ppchar = ^Pchar;
function initREAC(host_list:ppchar):integer;stdcall;external 'REAC.dll';
procedure Tfrm_main.Button1Click(Sender: TObject);
var
i:integer;
host_list:ppchar;
begin
i:=-1;
i:=REAC(host_list);
ShowMessage(IntToStr(i));
end;
每次运行都返回0,然后就提示在XXXXX地址存储错误。
本人想用Delphi调用一个Dll文件中的函数 int initREAC(char ** host_list)。
下边是函数调用的说明
// 返回值:0 - 成功, -1 - 失败
// 参数:host_list - 通讯主机列表,如:{"192.168.0.20", "192.168.0.21", ""}
// 说明:如果host_list 为NULL,则自动到动态库所在的目录下找host.lst文件获取主机列表
// host.lst格式为:
/*
192.168.0.20
192.168.0.21
*/
这里是该Dll文件的调用例子
int ret;
char * host_list[3] = {"192.168.0.2", "192.168.0.3", ""};
ret = initREAC(host_list);
我对C语言了解的有限,请各位帮忙提供一段Delphi的转换代码。谢谢!!
下边是我写的一段程序,总是有错误
type
ppchar = ^Pchar;
function initREAC(host_list:ppchar):integer;stdcall;external 'REAC.dll';
procedure Tfrm_main.Button1Click(Sender: TObject);
var
i:integer;
host_list:ppchar;
begin
i:=-1;
i:=REAC(host_list);
ShowMessage(IntToStr(i));
end;
每次运行都返回0,然后就提示在XXXXX地址存储错误。