又一个网上找来的版本,和之前的python版、php版功能一样,只不过换成了VBS来查询:

  1Class TQQWry
  2    ' ============================================
  3    ' 变量声名
  4    ' ============================================
  5    Public Country, LocalStr
  6    Public QQWryFile
  7    Private Buf, OffSet
  8    Private StartIP, EndIP, CountryFlag
  9    Private FirstStartIP, LastStartIP, RecordCount
 10    Private Stream, EndIPOff
 11    ' ============================================
 12    ' 类模块初始化
 13    ' ============================================
 14    Private Sub Class_Initialize
 15        Country       = ""
 16        LocalStr      = ""
 17        StartIP       = 0
 18        EndIP         = 0
 19        CountryFlag   = 0
 20        FirstStartIP  = 0
 21        LastStartIP   = 0
 22        EndIPOff      = 0
 23        QQWryFile     = "QQWry.Dat"
 24    End Sub
 25    ' ============================================
 26    ' 类终结
 27    ' ============================================
 28    Private Sub Class_Terminate
 29        On ErrOr Resume Next
 30        Stream.Close
 31        If Err Then Err.Clear
 32        Set Stream = Nothing
 33    End Sub
 34    ' ============================================
 35    ' IP地址转换成整数
 36    ' ============================================
 37    Function IPToInt(IP)
 38        Dim IPArray, i
 39        IPArray = Split(IP, ".", -1)
 40        FOr i = 0 to 3
 41            If Not IsNumeric(IPArray(i)) Then IPArray(i) = 0
 42            If CInt(IPArray(i))  255 Then IPArray(i) = 255
 43        Next
 44        IPToInt = (CInt(IPArray(0))*256*256*256) + (CInt(IPArray(1))*256*256) + (CInt(IPArray(2))*256) + CInt(IPArray(3))
 45    End Function
 46    ' ============================================
 47    ' 整数逆转IP地址
 48    ' ============================================
 49    Function IntToIP(IntValue)
 50        p4 = IntValue - Fix(IntValue/256)*256
 51        IntValue = (IntValue-p4)/256
 52        p3 = IntValue - Fix(IntValue/256)*256
 53        IntValue = (IntValue-p3)/256
 54        p2 = IntValue - Fix(IntValue/256)*256
 55        IntValue = (IntValue - p2)/256
 56        p1 = IntValue
 57        IntToIP = Cstr(p1) & "." & Cstr(p2) & "." & Cstr(p3) & "." & Cstr(p4)
 58    End Function
 59    ' ============================================
 60    ' 获取开始IP位置
 61    ' ============================================
 62    Private Function GetStartIP(RecNo)
 63        OffSet = FirstStartIP + RecNo * 7
 64        Stream.Position = OffSet
 65        Buf = Stream.Read(7)
 66        EndIPOff = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256)
 67        StartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
 68        GetStartIP = StartIP
 69    End Function
 70    ' ============================================
 71    ' 获取结束IP位置
 72    ' ============================================
 73    Private Function GetEndIP()
 74        Stream.Position = EndIPOff
 75        Buf = Stream.Read(5)
 76        EndIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
 77        CountryFlag = AscB(MidB(Buf, 5, 1))
 78        GetEndIP = EndIP
 79    End Function
 80    ' ============================================
 81    ' 获取地域信息,包含国家和和省市
 82    ' ============================================
 83    Private Sub GetCountry(IP)
 84        If (CountryFlag = 1 Or CountryFlag = 2) Then
 85            Country = GetFlagStr(EndIPOff + 4)
 86            If CountryFlag = 1 Then
 87                LocalStr = GetFlagStr(Stream.Position)
 88                ' 以下用来获取数据库版本信息
 89                If IP >= IPToInt("255.255.255.0") And IP  127 Then
 90                If Stream.EOS Then Exit Do
 91                GetStr = GetStr & Chr(AscW(ChrB(AscB(Stream.Read(1))) & ChrB(C)))
 92            Else
 93                GetStr = GetStr & Chr(c)
 94            End If
 95        Loop
 96    End Function
 97    ' ============================================
 98    ' 核心函数,执行IP搜索
 99    ' ============================================
100    Public Function QQWry(DotIP)
101        Dim IP, nRet
102        Dim RangB, RangE, RecNo
103        IP = IPToInt (DotIP)
104        Set Stream = CreateObject("ADodb.Stream")
105        Stream.Mode = 3
106        Stream.Type = 1
107        Stream.Open
108        Stream.LoadFromFile QQWryFile
109        Stream.Position = 0
110        Buf = Stream.Read(8)
111        FirstStartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
112        LastStartIP = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256) + (AscB(MidB(Buf, 8, 1))*256*256*256)
113        RecordCount = Int((LastStartIP - FirstStartIP)/7)
114        ' 在数据库中找不到任何IP地址
115        If (RecordCount  StartIP) Then
116                RangB = RecNo
117            Else
118                RangE = RecNo
119            End If
120        Loop
121        Call GetStartIP(RangB)
122        Call GetEndIP()
123        If (StartIP = IP) Then
124            ' 没有找到
125            nRet = 0
126        Else
127            ' 正常
128            nRet = 3
129        End If
130        Call GetCountry(IP)
131        QQWry = nRet
132    End Function
133End Class
134Set Wry = New TQQWry
135Wry.QQWry("8.8.8.8")
136WScript.Echo Wry.Country & "/" & Wry.LocalStr