希網(wǎng)動態(tài)域名IP更新工具 源代碼
希網(wǎng)動態(tài)域名IP更新工具 源代碼(Delphi)2008-04-12 01:57程序代碼 unit Unit1;interfaceusesWindows, Messages, SysUtils, Va
希網(wǎng)動態(tài)域名IP更新工具 源代碼(Delphi)2008-04-12 01:57程序代碼
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('希網(wǎng)動態(tài)域名設(shè)置','Username','xxxxxx');
bsSkinDBPasswordEdit1.Text:=IniFile.ReadString('希網(wǎng)動態(tài)域名設(shè)置','Password','xxxxx');
edit3.Text:=IniFile.ReadString('希網(wǎng)動態(tài)域名設(shè)置','Hostname','xxxx.3322.org');
freeAndNil(IniFile);
edit4.Text:=GetLocalIP;
end;
procedure TForm1.Button1Click(Sender: TObject);
varr