我这里有取“机器名”与“IP地址”的程序一份,供大家参考,但登陆用户就不知道
to 晓风月 你的原码能给我一份吗?E-mail:happyking21@sohu.com
procedure GetHostInfo(var Name, Address: string; var IpAddr : Integer);
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
WSAStartup(2, WSAData); //调用API启动WinSock
SetLength(Name, 255);
Gethostname(PChar(Name), 255); //调用API取得本机名称
SetLength(Name, StrLen(PChar(Name)));
HostEnt := gethostbyname(PChar(Name));
with HostEnt^ do
begin
Address:=Format('%d.%d.%d.%d',[Byte(h_addr^[0]),Byte(h_addr^[1]),
Byte(h_addr^[2]),Byte(h_addr^[3])]);
IpAddr := Byte(h_addr^[0]) shl 24 + Byte(h_addr^[1]) shl 16 +
Byte(h_addr^[2]) shl 8 +Byte(h_addr^[3]);
end;
WSACleanup;
end;