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

📄 unit1.~pas

📁 希网动态域名IP更新工具.自动更新3322的动态域名
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,winsock,wininet, WinSkinStore, WinSkinData,
  bsSkinCtrls, bsSkinBoxCtrls, bsdbctrls,inifiles;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    SkinData1: TSkinData;
    bsSkinDBPasswordEdit1: TbsSkinDBPasswordEdit;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function   GetLocalIP:string;
  type
          TaPInAddr   =   array   [0..10]   of   PInAddr;
          PaPInAddr   =   ^TaPInAddr;
  var
          phe     :   PHostEnt;
          pptr   :   PaPInAddr;
          Buffer   :   array   [0..63]   of   char;
          I         :   Integer;
          GInitData             :   TWSADATA;
  begin
          WSAStartup($101,   GInitData);
          Result   :=   '';
          GetHostName(Buffer,   SizeOf(Buffer));
          phe   :=GetHostByName(buffer);
          if   phe   =   nil   then   Exit;   
          pptr   :=   PaPInAddr(Phe^.h_addr_list);
          I   :=   0;
          while   pptr^[I]   <>   nil   do   begin
              result:=StrPas(inet_ntoa(pptr^[I]^));
              Inc(I);
          end;
          WSACleanup;   
  end;
  function GetWebPage(const Url: string):string;
var
  Session,
  HttpFile:HINTERNET;
  szSizeBuffer:Pointer;
  dwLengthSizeBuffer:DWord;
  dwReserved:DWord;
  dwFileSize:DWord;
  dwBytesRead:DWord;
  Contents:PChar;
begin
  Session:=InternetOpen('',0,niL,niL,0);
  HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
  dwLengthSizeBuffer:=1024;
  HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved);
  GetMem(Contents,dwFileSize);
  InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
  InternetCloseHandle(HttpFile);
  InternetCloseHandle(Session);
  Result:=StrPas(Contents);
  FreeMem(Contents);
end;


procedure TForm1.FormCreate(Sender: TObject);
var
IniFile:Tinifile;
myinifile:string;
begin
myinifile:=ExtractFilePath(paramstr(0))+'Config.ini';
IniFile:=Tinifile.Create(myinifile);
edit1.Text:=IniFile.ReadString('希网动态域名设置','Username','xxxxxx');
bsSkinDBPasswordEdit1.Text:=IniFile.ReadString('希网动态域名设置','Password','xxxxx');
edit3.Text:=IniFile.ReadString('希网动态域名设置','Hostname','xxxx.3322.org');
freeAndNil(IniFile);
edit4.Text:=GetLocalIP;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
username,password,test,hostname,myip,strurl:string;
begin
username:=edit1.Text;
password:=bsSkinDBPasswordEdit1.Text;
hostname:=edit3.Text;
myip:=edit4.Text;
test:='http://'+username+':'+password+'@members.3322.org/dyndns/update?system=dyndns&hostname='+hostname+'&myip='+myip+'&wildcard=ON&mx=&backmx=NO&offline=NO';
strurl:=GetWebPage(test);
if copy(strurl,0,4)='good' Then
showmessage('你的希网动态域名IP更新成功!')
else
if copy(strurl,0,5)='nochg' then
showmessage('目前你的动态域名是这个IP,不需要再次更新!')
else
showmessage('更新失败,可能是你的用户或密码,域名输入错误,请重新输入!');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
IniFile:Tinifile;
myinifile:string;
begin
myinifile:=ExtractFilePath(paramstr(0))+'Config.ini';
IniFile:=Tinifile.Create(myinifile);
IniFile.WriteString('希网动态域名设置','Username',edit1.text);
IniFile.WriteString('希网动态域名设置','Password',bsSkinDBPasswordEdit1.Text);
IniFile.WriteString('希网动态域名设置','Hostname',edit3.text);
freeAndNil(IniFile);
showmessage('你的希网动态域名设置已更改成功!');
end;

end.

⌨️ 快捷键说明

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