打印本文 打印本文 关闭窗口 关闭窗口
MX记录获取组件(vb实现)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2680  更新时间:2009/4/23 18:59:20  文章录入:mintao  责任编辑:mintao
    '''' The class of query (1 means INET)
    iTemp = htons(1)
    MemCopy dnsQuery(dnsQueryNdx), iTemp, Len(iTemp)
    dnsQueryNdx = dnsQueryNdx + Len(iTemp)
   
    On Error Resume Next
    ReDim Preserve dnsQuery(dnsQueryNdx - 1)
    '''' Send the query to the DNS server
    objWinSock.RemoteHost = DNS_Addr
    DNSrecieved = False
    objWinSock.SendData dnsQuery
   
    If WaitUntilTrue(DNSrecieved, 60) = False Then
        ''''MX_Query = ""
        Exit Function
    End If
   
    Dim iAnCount As Integer
    '''' Get the number of answers
    MemCopy iAnCount, dnsReply(6), 2
    iAnCount = ntohs(iAnCount)
    '''' Parse the answer buffer
    MX_Query = Trim(GetMXName(dnsReply(), 12, iAnCount))
   
End Function

Private Function WaitUntilTrue(ByRef Flag As Boolean, ByVal SecondsToWait As Long) As Boolean

    Dim fStart              As Single
    Dim fTimetoQuit         As Single

    fStart = Timer

    '''' Deal with timer being reset at Midnight
    If fStart + SecondsToWait < 86400 Then
        fTimetoQuit = fStart + SecondsToWait
    Else
        fTimetoQuit = (fStart - 86400) + SecondsToWait
    End If

    Do Until Flag = True
        If Timer >= fTimetoQuit Then
            WaitUntilTrue = Flag
            Exit Function
        End If
        DoEvents
        Sleep (10)   
    Loop

    WaitUntilTrue = Flag

End Function

极品源码,无限精彩,尽在 http://www.aspcdrom.com


 

上一页  [1] [2] [3] 

打印本文 打印本文 关闭窗口 关闭窗口