转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
MX记录获取组件(vb实现)         ★★★★

MX记录获取组件(vb实现)

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2085 更新时间:2009/4/23 18:59:20

源码是老外的,俺做了点修改,写成了dll

方法:

Public Function GetDNSinfo() As String

获取dns信息

Public Function MX_Query(DNS_Addr As String, ByVal Domain_Addr As String) As String

获取mx最佳记录,

dns_addr,域名解析服务器,可以用getdnsinfo获取,也可以用nslookup命令

domain_addr,想要获取邮件服务器的域名,如163.com ,hotmail.com

http://www.aspcdrom.com/down/mxquery.rar

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  ''''True
  Persistable = 0  ''''NotPersistable
  DataBindingBehavior = 0  ''''vbNone
  DataSourceBehavior  = 0  ''''vbNone
  MTSTransactionMode  = 0  ''''NotAnMTSObject
END
Attribute VB_Name = "mxquery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private WithEvents objWinSock As MSWinsockLib.Winsock
Attribute objWinSock.VB_VarHelpID = -1

Private Const ERROR_BUFFER_OVERFLOW = 111

Private DNSrecieved As Boolean
Private dnsReply() As Byte

Private Declare Function GetNetworkParams Lib "IPHlpApi" (FixedInfo As Any, pOutBufLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Declare Sub MemCopy Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb&)
Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer
Private Declare Function ntohs Lib "wsock32.dll" (ByVal netshort As Long) As Integer

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Const DNS_RECURSION As Byte = 1
Private Const MAX_HOSTNAME_LEN = 132
Private Const MAX_DOMAIN_NAME_LEN = 132
Private Const MAX_SCOPE_ID_LEN = 260
Private Const MAX_ADAPTER_NAME_LENGTH = 260
Private Const MAX_ADAPTER_ADDRESS_LENGTH = 8
Private Const MAX_ADAPTER_DESCRIPTION_LENGTH = 132

Private Type IP_ADDR_STRING
            Next As Long
            IpAddress As String * 16
            IpMask As String * 16
            Context As Long
End Type

Private Type FIXED_INFO
            HostName As String * MAX_HOSTNAME_LEN
            DomainName As String * MAX_DOMAIN_NAME_LEN
            CurrentDnsServer As Long
            DnsServerList As IP_ADDR_STRING
            NodeType As Long
            ScopeId  As String * MAX_SCOPE_ID_LEN
            EnableRouting As Long
            EnableProxy As Long
            EnableDns As Long
End Type

Private Type DNS_HEADER
    qryID As Integer
    options As Byte
    response As Byte
    qdcount As Integer
    ancount As Integer
    nscount As Integer
    arcount As Integer
End Type

Private Type HostEnt
    h_name As Long
    h_aliases As Long
    h_addrtype As Integer
    h_length As Integer
    h_addr_list As Long
End Type

Private Const hostent_size = 16

Private Type servent
    s_name As Long
    s_aliases As Long
    s_port As Integer
    s_proto As Long
End Type

Private Function MakeQName(sDomain As String) As String
    Dim iQCount As Integer      '''' Character count (between dots)
    Dim iNdx As Integer         '''' Index into sDomain string
    Dim iCount As Integer       '''' Total chars in sDomain string
    Dim sQName As String        '''' QNAME string
    Dim sDotName As String      '''' Temp string for chars between dots
    Dim sChar As String         '''' Single char from sDomain string
   
    iNdx = 1
    iQCount = 0
    iCount = Len(sDomain)
    '''' While we haven''''t hit end-of-string
    While (iNdx <= iCount)
        '''' Read a single char from our domain
        sChar = Mid(sDomain, iNdx, 1)
        '''' If the char is a dot, then put our character count and the part of the string
        If (sChar = ".") Then
            sQName = sQName & Chr(iQCount) & sDotName
            iQCount = 0
            sDotName = ""
        Else
            sDotName = sDotName + sChar
            iQCount = iQCount + 1
        End If
        iNdx = iNdx + 1
    Wend
   
    sQName = sQName & Chr(iQCount) & sDotName
   
    MakeQName = sQName
End Function
Private Sub ParseName(dnsReply() As Byte, iNdx As Integer, sName As String)
    Dim iCompress As Integer        '''' Compression index (index into original buffer)
    Dim iChCount As Integer         '''' Character count (number of chars to read from buffer)
       
    '''' While we didn''''t encounter a null char (end-of-string specifier)
    While (dnsReply(iNdx) <> 0)
        '''' Read the next character in the stream (length specifier)
        iChCount = dnsReply(iNdx)
        '''' If our length specifier is 192 (0xc0) we have a compressed string
        If (iChCount = 192) Then
            '''' Read the location of the rest of the string (offset into buffer)
            iCompress = dnsReply(iNdx + 1)
            '''' Call ourself again, this time with the offset of the compressed string
            ParseName dnsReply(), iCompress, sName
            '''' Step over the compression indicator and compression index
            iNdx = iNdx + 2
            '''' After a compressed string, we are done
            Exit Sub
        End If
       
        '''' Move to next char
        iNdx = iNdx + 1
        '''' While we should still be reading chars
        While (iChCount)
            '''' add the char to our string
            sName = sName + Chr(dnsReply(iNdx))
            iChCount = iChCount - 1
            iNdx = iNdx + 1
        Wend
        '''' If the next char isn''''t null then the string continues, so add the dot
        If (dnsReply(iNdx) <> 0) Then sName = sName + "."
    Wend
End Sub


Private Function GetMXName(dnsReply() As Byte, iNdx As Integer, iAnCount As Integer) As String
    Dim iChCount As Integer     '''' Character counter
    Dim sTemp As String         '''' Holds original query string
   
    Dim iMXLen As Integer
    Dim iBestPref As Integer &nbs

[1] [2] [3]  下一页


[VB.NET程序]循环链表以及相关操作(VB实现)  [VB.NET程序]浏览文件夹中的图片(用VB实现)
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

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

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

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

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

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

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