delphi中用socket解析域名获得IP地址


本文整理自网络,侵删。

 

需引用WinSock单元

 

 

var  

    WSAData:TWSAData;  
    Socket1:TSocket;  
    Addr:TSockAddr;  
    Re:Integer;  
begin  
    //初始化WinSock   
    if (WSAStartup(MakeWord(2,0), WSAData) <> 0) then  
    begin  
        mmo1.Lines.Add('WinSock初始化失败!');  
        Exit;  
    end  
    else  
    mmo1.Lines.Add('WinSock开始运行……');  
    mmo1.Lines.Add(inet_ntoa(PInAddr(gethostbyname('www.hao828.com')^.h_addr_list^)^));  

相关阅读 >>

Delphi strtodatetime 这个函数在win7下出错

Delphi中读取指定内存地址的值

Delphi抓取qq聊天窗口实例

Delphi 通过wmi获取u盘硬件特征码

Delphi firedac 连接access mdb数据库的方法

Delphi源码webbrowser多次执行documentcomplete

Delphi string内存结构

Delphi apihook createprocess

Delphi研究之驱动开发篇(七)--利用共享内存与用户模式

Delphi dateof、timeof、yearof、monthof、weekof、dayof、hourof、minuteof、secondof、millisecondof �c 提取时间成分

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...