Форум: "Сети";
Текущий архив: 2002.04.11;
Скачать: [xml.tar.bz2];
ВнизОпять поднимаю вопрос, как определить в Delphi IP адрес полученный от проваёдера? Найти похожие ветки
← →
copyr25 (2002-01-26 07:13) [20]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Winsock;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function GetLocalIP: String;
type
PPInAddr = ^PInAddr;
var
wsaData: TWSAData;
HostInfo: PHostEnt;
HostName: Array[0..255] of Char;
Addr: PPInAddr;
begin
Result := "";
if WSAStartup($0102, wsaData) <> 0 then
exit;
try
if gethostname(HostName, SizeOf(HostName)) <> 0 then
exit;
HostInfo := gethostbyname(HostName);
if HostInfo = nil then
exit;
Addr := Pointer(HostInfo^.h_addr_list);
if (Addr = nil) or (Addr^ = nil) then
exit;
Result := StrPas(inet_ntoa(Addr^^));
inc(Addr);
while Addr^ <> nil do
begin
Result := Result + ^M^J + StrPas(inet_ntoa(Addr^^));
inc(Addr);
end;
finally
WSACleanup;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=GetLocalIP;
end;
end.
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2002.04.11;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.007 c