鏀惰棌 (0) +1 璧� (0) +1 韪� (0) +1
鏀惰棌鎴愬姛鏌ョ湅鏀惰棌>>

正在阅读:VB学习:MX记录获取组件VB学习:MX记录获取组件

2004-03-10 09:52 出处:CSDN 作者:glling 责任编辑:linjixiong

  ' The type of query (15 means MX query)
  iTemp = htons(15)
  MemCopy dnsQuery(dnsQueryNdx), iTemp, Len(iTemp)
  dnsQueryNdx = dnsQueryNdx + Len(iTemp)

  ' 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




察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
鎵嬫満璁块棶鍥炲埌椤堕儴