⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 < Delphi网络通信协议分析与应用实现>>一书的源代码。
💻 PAS
字号:
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
type
  //copy the add_list
  TAddrList = array [0..20] of PInAddr;
  PAddrList = ^TAddrList;
var
  phent : PHostEnt;
  P: PAddrList;
  I : Integer;
begin
{ CopyRight (C) Bowman 2000 }
{ MatthewBowman@21cn.com }
   //detect yahoo.com
   phent := GetHostByName(pchar(edit1.text));
   if phent<>nil then
     begin
        I := 0;
        P := PAddrList(phent^.h_Addr_list);
        while P[I] <> nil do
        begin
            listbox1.items.Add(StrPas(inet_ntoa(P[I]^)));
            Inc(I)
        end
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
      WSAData : TWSAData;
begin
     //initiates use of WS2_32.DLL
     if (WSAStartup(MAKEWORD(2,0),WSAData)<>0) then
        raise Exception.Create('Winsock Version Error');
end;


procedure TForm1.FormDestroy(Sender: TObject);
begin
     WSACleanUP;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -