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 := GetHostByName(@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);
if i<4 then
Ipstr := Ipstr + Ip + '.'
else
Edit1.Text:=Ipstr+Ip;
end;
end;
WSACleanup;
end;
end.Edit3.Text := Chr(Host.h_addrtype+64);为什么要加64?
Ip:=IntToStr(Ord(Host.h_addr^[i-1]));什么意思
begin
ShowMessage('WS2_32.DLL初始化失败!');
halt;
end;
try
if GetHostName(@Buffer[1],32)<>0 then
begin
ShowMessage('没有得到主机名!');
halt;
end;
except
ShowMessage('没有成功返回主机名');
halt;
end;
Host := GetHostByName(@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);
if i<4 then
Ipstr := Ipstr + Ip + '.'
else
Edit1.Text:=Ipstr+Ip;
end;
end;
WSACleanup;
end;
end.Edit3.Text := Chr(Host.h_addrtype+64);为什么要加64?
Ip:=IntToStr(Ord(Host.h_addr^[i-1]));什么意思
解决方案 »
- 请教如何判断TADBQuery是否已经打开?
- dbgrideh汇总
- 求bmp文件转bin文件代码,急?
- 如何限制同一台机器只允许运行一个相同应用程序??
- 请教各位一个问题,Delphi在打开项目时,有时会出现这样错误。Error creating form:"is not a valid floating point value.是什么原因?
- Tcombobox控件使用问题
- 请教有编程经验的高手问题
- 我用VB写的Com中有显示非模式窗体,但是Dephi调用时提示错误怎么办?
- 這問題有點意思。。。
- 一个关于局域网的问题?
- 怎样一次性创建多级目录?
- 如何用Delphi编程实现对数据库的操作,从而将SQL Server数据表中的数据导入到oracle数据表中?
Host.h_addrtype的值为1-4的整数,加64是为了显示成"A"或"B"或"C"……等字符
IntToStr(Ord(Host.h_addr^[i-1]));
Host.h_addr^共占四个字节, 分别是IP地址的那四个数,这个表示式是为了以十进制字符串的形式显示出这四个数。