这是什么错误,看不懂?

qukmei 2003-02-12 03:40:55
[Error] d.pas(57): Not enough actual parameters
...全文
40 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
qukmei 2003-02-12
  • 打赏
  • 举报
回复
不错,谢谢你了,我今天下午刚学 delphi6.0
书上写错了,书也有bug?晕
谢谢了,结贴!
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
如果我估计不错,第二次调用应该是这个函数:gethostbyname
那你原来的程序别的都不用动,只要把第二次调用的函数名改了就可以了
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
把host的定义改为host:integer;
将if host=nil改为if host<>0
你这段程序从哪里来的?按照delphi的帮助返回的host_name存放在buffer中,
这样和你的程序就完全不一样了。
你的第一次调用GetHostName是正确的,第二次就有点莫名其妙了,
可能程序有误
qukmei 2003-02-12
  • 打赏
  • 举报
回复
看不懂,直接点的,只要能改对了这个程序,我是delphi6.0,为什么就是报错!晕
jakefj 2003-02-12
  • 打赏
  • 举报
回复
TGetHostNameProc = function (name: PChar; len: Integer): Integer;

qukmei 2003-02-12
  • 打赏
  • 举报
回复
怎么改呀,高手们?
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
那是你的返回值定义有错,GetHostName的返回值是integer!
qukmei 2003-02-12
  • 打赏
  • 举报
回复
[Error] d.pas(58): Incompatible types: 'Integer' and 'PHostEnt'

加上是这个错,晕的
qukmei 2003-02-12
  • 打赏
  • 举报
回复
加上也错!为什么?
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
你那里是少了一个参数嘛,你前面还有一个,就加了个32。后面的为什么不加
qukmei 2003-02-12
  • 打赏
  • 举报
回复
看不懂呀
你们看就是那句有问题呀,为什么?

unit d;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Winsock;

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Ip:String;
Ipstr:String;
Buffer:Array[1..32] of Char;
i:Integer;
WSData:TWSAData;
Host:PHostEnt;

begin
if WSAstartup(2,WSData)<>0 then
begin
showmessage('WS2_32.DLL初始化失败!');
halt;
end;
try
if GetHostName(@Buffer[1],32)<>0 then
begin
showmessage('没有得到主机名');
halt;
end;
except
showmessage('没有成功返回主机名!');
halt;
end;
Host:=GetHostName (@Buffer[1]); //这句报错!
if Host=nil then
begin
showmessage('ip地址为空!');
halt;
end
else
begin
Edit2.Text:=Host.h_name;
Edit3.Text:=Chr(Host.h_addrtype+64);
for i:=1 to 4 do
begin
Ip:=IntToStr(Ord(Host.h_addr^[i-1]));
showmessage('分段ip地址为:'+Ip);
Ipstr:=Ipstr+Ip;
if i<4 then
Ipstr:=Ipstr+'.'
else
Edit1.Text:=Ipstr;
end;
end;
WSACleanup;

end;

end.
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
你试试,我也不知道行不行

var
s:string;
begin
setlength(s,50);
gethostname(pchar(s),50);
end;
qukmei 2003-02-12
  • 打赏
  • 举报
回复
我倒,我的那个怎么改呀?帮
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
int gethostname (

char FAR * name,
int namelen
);
除了pchar外还有integer
蝈蝈太阳 2003-02-12
  • 打赏
  • 举报
回复
up
killedkiss 2003-02-12
  • 打赏
  • 举报
回复
c_hk(小李抢刀) :GetHostName函数是干吗用的??
qukmei 2003-02-12
  • 打赏
  • 举报
回复
我定义的是:
Buffer:Array[1..32] of Char;
goomoo 2003-02-12
  • 打赏
  • 举报
回复
实参不够数。请察看函数原型。
c_hk 2003-02-12
  • 打赏
  • 举报
回复
var
Bufffer : Array[0..255] of Char;
...
Host:=GetHostName (@Buffer);
netwolfds 2003-02-12
  • 打赏
  • 举报
回复
少了参数,GetHostName 有两个参数
加载更多回复(1)

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧