unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,winsock, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function HostToIP(Name: string; var Ip: string): Boolean;   //hosttoip 函数作用是将域名解析成ip
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.Button1Click(Sender: TObject);
var     //定义一个字符串变量
Temp:string;
begin
HostToIP(edit1.text,Temp); //将输入的域名解析成IP
edit2.Text:=Temp; //显示在EDIT2当中

end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.

域名解析-delphi 源码的更多相关文章

  1. [源码]Delphi源码免杀之函数动态调用 实现免杀的下载者

    [免杀]Delphi源码免杀之函数动态调用 实现免杀的下载者 2013-12-30 23:44:21         来源:K8拉登哥哥's Blog   自己编译这份代码看看 过N多杀软  没什么技 ...

  2. QQ2008自动聊天精灵delphi源码

    QQ2008自动聊天精灵delphi源码   unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Grap ...

  3. 转换GMT秒数为日期时间格式-Delphi源码

    转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...

  4. http代理工具delphi源码

    http://www.caihongnet.com/content/xingyexinwen/2013/0721/730.html http代理工具delphi源码 以下代码在 DELPHI7+IND ...

  5. 植物大战僵尸中文第二版和年度版 游戏分析及delphi源码

    00413184 |. E8 77E30100   |CALL PlantsVs.00431500                  ; 地上的物品00413189 |. 8D7424 10     ...

  6. 59 pages的Delphi源码

    http://www.codesc.net/source/list_10_59.shtml

  7. CRC8算法DELPHI源码

    unit Crc8; interface Uses Classes, Windows; Function Crc_8n(p : array of BYTE; len : BYTE) : Byte; i ...

  8. 我来解数独(附delphi源码)

    前段时间看到“69岁农民3天破解世界最难数独游戏”,然后在看了那个号称世界最难的数独题目之后,就打算抽空编程解决.今晚抽出一个晚上,大约四五个小时的时间,中间还间歇在clash of clans上造兵 ...

  9. 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名

    {-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...

随机推荐

  1. Retina

    走向Retina Web RETINA时代的前端优化 <!DOCTYPE html> <html> <head> <meta charset="ut ...

  2. SharePoint 2010中使用SPListItemCollectionPosition更快的结果

    转:http://www.16kan.com/article/detail/318657.html Introduction介绍 In this article we will explore the ...

  3. MySQL数据库的优化-运维架构师必会高薪技能,笔者近六年来一线城市工作实战经验

    原文地址:http://liangweilinux.blog.51cto.com/8340258/1728131 首先在此感谢下我的老师年一线实战经验,我当然不能和我的老师平起平坐,得到老师三分之一的 ...

  4. selenium webdriver(4)---模拟鼠标键盘操作

    webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...

  5. input hidden用法

    之前获取数据传数据,都是写在全局变量里,今天老板告诉我说用input hidden来存,我百度了一下,确实是个好方法,记录之: 1 隐藏域在页面中对于用户是不可见的,在表单中插入隐藏域的目的在于收集或 ...

  6. Day 3 @ RSA Conference Asia Pacific & Japan 2016 (afternoon)

    13.30 hrs Keynote    Security in the World-Sized Web Bruce Schneier,Chief Technology Officer, Resili ...

  7. (转)JS正则表达式元字符

    正则 描述 正则 描述 \f 匹配换页符 \t 匹配制表符 \n 匹配换行符 \v 匹配垂直制表符 \r 匹配回车 \s 匹配单个空格,等同于[\f\n\r\t\v]; \S 表示非空格字符 \d 在 ...

  8. linux系统下安装apache与tomcat

    apache的安装 把安装包放到/soft 下 [root@localhost ~]#cd /soft [root@localhost soft]#tar jxvf httpd-2.2.25.tar. ...

  9. PAT---1050. String Subtraction (20)

    #include<iostream> #include<string.h> #include<stdio.h> using namespace std; #defi ...

  10. Android将Activity打成jar包供第三方调用(解决资源文件不能打包的问题)

    转载地址:http://blog.csdn.net/xiaanming/article/details/9257853 最近有一个需要,我们公司做了一个apk客户端,然后其他的公司可以根据自己的需要来 ...