域名解析-delphi 源码
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 源码的更多相关文章
- [源码]Delphi源码免杀之函数动态调用 实现免杀的下载者
[免杀]Delphi源码免杀之函数动态调用 实现免杀的下载者 2013-12-30 23:44:21 来源:K8拉登哥哥's Blog 自己编译这份代码看看 过N多杀软 没什么技 ...
- QQ2008自动聊天精灵delphi源码
QQ2008自动聊天精灵delphi源码 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Grap ...
- 转换GMT秒数为日期时间格式-Delphi源码
转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...
- http代理工具delphi源码
http://www.caihongnet.com/content/xingyexinwen/2013/0721/730.html http代理工具delphi源码 以下代码在 DELPHI7+IND ...
- 植物大战僵尸中文第二版和年度版 游戏分析及delphi源码
00413184 |. E8 77E30100 |CALL PlantsVs.00431500 ; 地上的物品00413189 |. 8D7424 10 ...
- 59 pages的Delphi源码
http://www.codesc.net/source/list_10_59.shtml
- CRC8算法DELPHI源码
unit Crc8; interface Uses Classes, Windows; Function Crc_8n(p : array of BYTE; len : BYTE) : Byte; i ...
- 我来解数独(附delphi源码)
前段时间看到“69岁农民3天破解世界最难数独游戏”,然后在看了那个号称世界最难的数独题目之后,就打算抽空编程解决.今晚抽出一个晚上,大约四五个小时的时间,中间还间歇在clash of clans上造兵 ...
- 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名
{-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...
随机推荐
- 修改mysql 数据库密码
第1种︰使用 mysqladmin命令 shell>mysqladmin -u root password new_password 如果忘记了MySQL的root密码,可以用以下方法重新设置: ...
- opengl学习
#include"stdafx.h" #define GLUT_DISABLE_ATEXIT_HACK #include <GL/glut.h> //glut自动将gl ...
- (转载)PHP数组传递是值传递而非引用传递
(转载)http://www.fengfly.com/plus/view-212127-1.html 在调用函数时通过将PHP数组作为实参赋给形参,在函数中修改,并不会影响到数组本身. 说明此过程中的 ...
- Method Overloading in WCF zt
Method overloading is the process of implementing Polymorphism in Object-Oriented Programming. A met ...
- 浅谈pageobject模式
先来看两段代码 代码1: package com.zlshuo.selenium.nonaming.pageobject; /** * @author leshuo * @version 2014年5 ...
- HDOJ/HDU 2565 放大的X(分段思考~)
Problem Description 请你编程画一个放大的'X'. 如3*3的'X'应如下所示: X X XX X5*5的'X'如下所示:X X X X X X XX X Input 输入数据第一行 ...
- 基于TCP协议的客户端
基于TCP协议的客户端 此客户端能用于下一篇博客的单线程服务器和多线程服务器 import java.io.BufferedReader; import java.io.IOException; im ...
- Spark Repl过程分析(源码)
- Install MongoDB on Windows
Overview Use this tutorial to install MongoDB on a Windows systems. PLATFORM SUPPORT Starting in ver ...
- javascript中String 对象slice 和substring 区别
1.slice(start,stop)和substring(start,stop) 方法都是用于提取字符串中从start开始到stop-1间的字符(因为字符串索引是从0开始).其中 start必 ...