foxter
Sep 17th, 2007, 04:40 PM
Just posting it in case if anyone needs it. Please do post replies if you have any suggestions:
Option Explicit
'drop 2 text boxes, a command button, and a winsock control on your form
Private sWinsockCommand As String
Private sDataIn As String
Private sDataBuff As String
Private Sub Command1_Click()
'whois ("domain.com")
whois (Text1.Text)
End Sub
Private Sub Form_Load()
Winsock1.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub
Private Sub Winsock1_Close()
If Winsock1.State = sckClosing Then
Winsock1.Close
Text2.Text = ""
sDataBuff = Replace(sDataBuff, vbLf, vbCrLf)
Text2.Text = sDataBuff
End If
End Sub
Private Sub Winsock1_Connect()
If Winsock1.State = sckConnected Then
Winsock1.SendData sWinsockCommand & vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData sDataIn
sDataBuff = sDataBuff & sDataIn
End Sub
Private Function whois(domain As String)
Dim sServer As String
sDataIn = ""
sDataBuff = ""
If Right(Text1.Text, 4) = ".com" Then sServer = "rs.internic.net"
If Right(Text1.Text, 4) = ".net" Then sServer = "rs.internic.net"
If Right(Text1.Text, 4) = ".org" Then sServer = "whois.publicinterestregistry.net"
If Right(Text1.Text, 4) = ".edu" Then sServer = "whois.educause.net"
If Right(Text1.Text, 4) = ".gov" Then sServer = "whois.nic.gov"
If Right(Text1.Text, 5) = ".info" Then sServer = "whois.afilias.info"
If Right(Text1.Text, 3) = ".ru" Then sServer = "whois.ripn.ru"
sWinsockCommand = domain
With Winsock1
.Close
.LocalPort = 0
.Connect sServer, 43
whois = .State = sckResolvingHost
End With
End Function
:afrog:
Option Explicit
'drop 2 text boxes, a command button, and a winsock control on your form
Private sWinsockCommand As String
Private sDataIn As String
Private sDataBuff As String
Private Sub Command1_Click()
'whois ("domain.com")
whois (Text1.Text)
End Sub
Private Sub Form_Load()
Winsock1.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub
Private Sub Winsock1_Close()
If Winsock1.State = sckClosing Then
Winsock1.Close
Text2.Text = ""
sDataBuff = Replace(sDataBuff, vbLf, vbCrLf)
Text2.Text = sDataBuff
End If
End Sub
Private Sub Winsock1_Connect()
If Winsock1.State = sckConnected Then
Winsock1.SendData sWinsockCommand & vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData sDataIn
sDataBuff = sDataBuff & sDataIn
End Sub
Private Function whois(domain As String)
Dim sServer As String
sDataIn = ""
sDataBuff = ""
If Right(Text1.Text, 4) = ".com" Then sServer = "rs.internic.net"
If Right(Text1.Text, 4) = ".net" Then sServer = "rs.internic.net"
If Right(Text1.Text, 4) = ".org" Then sServer = "whois.publicinterestregistry.net"
If Right(Text1.Text, 4) = ".edu" Then sServer = "whois.educause.net"
If Right(Text1.Text, 4) = ".gov" Then sServer = "whois.nic.gov"
If Right(Text1.Text, 5) = ".info" Then sServer = "whois.afilias.info"
If Right(Text1.Text, 3) = ".ru" Then sServer = "whois.ripn.ru"
sWinsockCommand = domain
With Winsock1
.Close
.LocalPort = 0
.Connect sServer, 43
whois = .State = sckResolvingHost
End With
End Function
:afrog: