转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 站长学院 >> Web开发 >> 正文
将域名转IP的VB源代码         ★★★

将域名转IP的VB源代码

作者:闵涛 文章来源:闵涛的学习笔记 点击数:762 更新时间:2010/7/15 14:45:59

域名IP的VB源代码

以下是代码片段:
Option Explicit
'###################
'    敏韬网 www.mintao.net
'###################
Private Type HOSTENT
    hName As Long
    hAliases As Long
    hAddrType As Integer
    hLength As Integer
    hAddrList As Long
End Type
  
Private Type WSADATA
    wversion As Integer
    wHighVersion As Integer
    szDescription(0 To 256) As Byte
    szSystemStatus(0 To 128) As Byte
    iMaxSockets As Integer
    iMaxUdpDg As Integer
    lpszVendorInfo As Long
End Type
  
Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Integer, lpWSAData As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function gethostname Lib "WSOCK32.DLL" (ByVal szHostname As String, ByVal HostLen As Long) As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal szHostname As String) As Long
Private Declare Sub RtlMoveMemory Lib "KERNEL32" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
  
Private Const WS_VERSION_REQD = &H101
  
Private Function Test(URL As String) As String
    InitializeWinSock
    Test = GetAddressByName(URL) '    敏韬网 www.mintao.net
    TerminateWinSock
End Function
  
Private Function GetAddressByName(strHostname As String)
    Dim lngAddr As Long
    Dim udtHost As HOSTENT
    Dim lngIP As Long
    Dim bteTmp() As Byte
    Dim i As Integer
    Dim strIP As String
  
    lngAddr = gethostbyname(strHostname)
  
    If lngAddr = 0 Then
        MsgBox "Kein Host gefunden."
        GetAddressByName = Null
        Exit Function
    End If
  
    RtlMoveMemory udtHost, lngAddr, LenB(udtHost)
    RtlMoveMemory lngIP, udtHost.hAddrList, 4
  
    ReDim bteTmp(1 To udtHost.hLength)
    RtlMoveMemory bteTmp(1), lngIP, udtHost.hLength
    For i = 1 To udtHost.hLength
        strIP = strIP & bteTmp(i) & "."
    Next
    strIP = Mid$(strIP, 1, Len(strIP) - 1)
  
    GetAddressByName = strIP
End Function
  
Private Sub InitializeWinSock()
    Dim udtWSAD As WSADATA
    Dim lngRet As Long
    lngRet = WSAStartup(WS_VERSION_REQD, udtWSAD)
    If lngRet <> 0 Then
        MsgBox "Winsock.dll konnte nicht initialisiert werden."
        End
    End If
End Sub
'###################
'    敏韬网 www.mintao.net
'###################
Private Sub TerminateWinSock()
    Dim lngRet As Long
    lngRet = WSACleanup()
    If lngRet <> 0 Then
        MsgBox "Fehler " & lngRet & " beim Beenden von Winsock.dll" '    敏韬网 www.mintao.net
        End
    End If
End Sub
  
Private Sub Command1_Click()
    Dim MyURL As String
    MyURL = "www.btoss.com"
    MsgBox MyURL & "的IP地址是:" & Test(MyURL)
End Sub


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Web开发  · 网页制作
    · 平面设计  · 网站运营
    · 网站推广  · 搜索优化
    · 建站心得  · 站长故事
    · 互联动态
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    An error occurred on the server when processing the URL. Please contact the system administrator.

    If you are the system administrator please click here to find out more about this error.

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao 信息产业部ICP备案号:鄂ICP备11006601号

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台