将域名(DNS)解释成IP地址,去哪找这方面的知识??快快,急
解决方案 »
- 关于使用指针正确读写数据的问题。
- delphi 引用自定义函数报错
- 程序长时间没有动作而出现异常
- 请教,在Delphi中如何生成指定背景图片的图片(即在原背景图片上画图)
- delphi7 里打开带密码的access数据库时出现工作组信息文件丢失信息,请高手指点?
- 用CreateToolhelp32Snapshot获取进程快照时,有时为真,有时为假,不知道什么原因?
- 找工作_开价_散分!
- 【倒分热线】黑名单又添加新成员?!
- 会delphi的朋友请进:关于调用vc组件含safearray参数的方法,帮忙up也一定送分!
- 装好Kylix后,运行出错,“Runtime error 230 at 413A9497”
- 关于ActiveX控件的定义事件的问题!!!!!!!!!!!!!!!!!!!!!!!!!!????????????
- 关于Tquery控件的字段长度的问题
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Winsock;type
TFormMain = class(TForm)
Label1: TLabel;
Label2: TLabel;
EditPresentation: TEdit;
EditResult: TEdit;
edtHost:TEdit;
BtnGetHostByName: TButton;
Label3: TLabel; procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BtnGetHostByNameClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
FormMain: TFormMain;implementation{$R *.DFM}procedure TFormMain.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 TFormMain.FormDestroy(Sender: TObject);
begin
WSACleanUP;
end;
procedure TFormMain.BtnGetHostByNameClick(Sender: TObject);
var
Host: pHostent;
ConsultResult:String;
Err:Integer;
begin
Try
Host := GetHostByName(PChar(EditPresentation.Text));
Except
Err:=WSAGetLastError();
EditResult.Text:='Error Code:'+InttoStr(Err);
Exit;
end;
if Host=NIL then
begin
EditResult.Text:='Host does not exist';
exit;
end;
ConsultResult:=Copy(Host.h_addr^,0,4);
EditResult.Text:=Format('%d.%d.%d.%d',
[ord(ConsultResult[1]),
ord(ConsultResult[2]),
ord(ConsultResult[3]),
ord(ConsultResult[4])]);
edtHost.Text:=Host.h_name;
end;end.DELPHI网络编程中的第五章源码.
或者参考DEPHI中的help -> windows SDK