unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, winsock,ExtCtrls, shellapi, jpeg, Buttons;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Memo1: TMemo;
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure Image1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
 close;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
var
  ip:integer;
begin
 shellexecute(handle,'open','https://www.5yang.cc',nil,nil,sw_show);
end;

function HostToIP(Name: string; var Ip: string): Boolean;
var
  wsdata : TWSAData;
  hostName : array[0..255] of AnsiChar;
  hostEnt : PHostEnt;
  addr : PAnsiChar;
begin
  WSAStartup ($0101, wsdata);
  try
    gethostname (hostName, sizeof(hostName));
    StrPCopy(hostName, Name);
    hostEnt := gethostbyname (hostName);
    if Assigned (hostEnt) then
      if Assigned (hostEnt^.h_addr_list) then begin
        addr := hostEnt^.h_addr_list^;
        if Assigned (addr) then begin
          IP := Format ('%d.%d.%d.%d', [byte (addr [0]),
          byte (addr [1]), byte (addr [2]), byte (addr [3])]);
          Result := True;
        end
        else
          Result := False;
      end
      else
        Result := False
    else begin
      Result := False;
    end;
  finally
    WSACleanup;
  end
end;

procedure TForm1.Image1Click(Sender: TObject);
begin

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
 ip:string;
begin
 if edit1.text='' then
  messagebox(handle,'没有输入服务器地址!','登录提示',mb_ok+mb_iconinformation)
 else
  begin
   if hosttoip(edit1.Text,ip) then
    begin
     memo1.Clear;
     deletefile(extractfilepath(paramstr(0))+'addr.txt');
     memo1.Lines.Add(ip+',3053,千年,(电信)');
     memo1.Lines.SaveToFile(extractfilepath(paramstr(0))+'addr.txt');
     shellexecute(handle,'open',pchar(extractfilepath(paramstr(0))+'client.exe'),nil,nil,sw_show);
     close;
    end
   else
    messagebox(handle,'输入的服务器不能解析!','登录提示',mb_ok+mb_iconinformation);
  end;
end;

end.
最后修改:2022 年 12 月 05 日
如果觉得我的文章对你有用,请随意赞赏