Help, help me change the VB code to C #.

xiaoxiao2021-03-06  69

Any international domain name is recorded on the DNS (Domain Name Server), how do you query about a domain name? Like POP3 is used for receiving email, the WHOIS service is used to query domain information. This service is provided by INTERNIC in the US. This service is useful when you want to determine if a domain name exists or want to get the domain name registration information. First, the Winsock control provides all the information required to perform WHOIS to find. The steps are as follows: 1. Connect to the port 43 of the INTERNIC server. 2. Send domain names. 3. Read the reply from the server. 4. Disconnect the connection from the server. Second, the design interface and the source program:

The source program includes the above form and a module file, the code in the module is used to determine if the computer is connected.

1, the module code: Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias ​​"RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias ​​"RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long Public Const RAS95_MaxEntryName = 256 Public Const RAS95_MaxDeviceType = 16 Public Const RAS95_MaxDeviceName = 32 'Public Type RASCONN95 dwSize As Long hRasCon As Long szEntryName (RAS95_MaxEntryName) As Byte szDeviceType (RAS95_MaxDeviceType) As Byte szDeviceName (RAS95_MaxDeviceName) As Byte End Type Public Type RASCONNSTATUS95 dwSize As Long RasConnState As Long dwError As Long szDeviceType (RAS95_MaxDeviceType) As Byte szDeviceName (RAS95_MaxDeviceName) As Byte End Type 'custom function, determines whether the connection to the Internet Public function IsConnected () As Boolean DIM TRASCON (255) AS RASCONN95 DIM LG AS Long Dim LPCON AS Long Dim Retval As Long Dim TSTATUS As RasconnStatus95 Trascon (0) .dwsize = 412 lg = 256 * Trascon ( 0) .dwSize RetVal = RasEnumConnections (TRasCon (0), lg, lpcon) If RetVal <> 0 Then Exit Function End If Tstatus.dwSize = 160 RetVal = RasGetConnectStatus (TRasCon (0) .hRasCon, Tstatus) If Tstatus.RasConnState = & H2000 kilse isconnected = true else isconnected = false End ISCONNECTED = FALSE END ISCONNECTION 2 .Additem "whois.cnnic.net.net" .additem "whois.Opensrs.net" .additem "whois.networksolutions.com" .additem "whois.nic.gov" .additem "rsinternic.net" .additem " Whois.ripe.net ".additem"

whois.arin.net ".AddItem" whois.apnic.net ".AddItem" whois.aunic.net ".ListIndex = 0 End With End Sub Private Sub Send_Query_Button1_Click () Dim Selected_WhoIs_Server As String If IsConnected () = False Then MsgBox" not connected to the Internet. ", 64," prompt "Else Input_Label.Caption =" "WhoIs_Response =" " 'initialize Winsock Winsock.Close Winsock.LocalPort = 0 Selected_WhoIs_Server = Trim (WhoIs_Server.Text)' WHOIS server connected to a database, the port No. 43 Winsock.Connect Selected_WhoIs_Server, 43 End If End Sub Private Sub Winsock_Connect () 'connected WinSock and sends a domain name query request If Trim (Domain_Name) = "" Then WhoIs_Response = "No domain name was entered." Beep Exit Sub End If Winsock .SendData Trim (Domain_Name) & vbCrLf End Sub Private Sub Winsock_DataArrival (ByVal bytesTotal As Long) 'Winsock processing the received data stream Dim WhoIs_Data As String On Error GoTo ERROR_HANDLER Winsock.GetData WhoIs_Data Input_Label.Caption = Input_Label.Caption & WhoIs_Data WhoIs_Response = Input_Label .Caption exit sub 'error handling error_handler: whois_response = Error End Sub III, the function provided by this program can only query international domain names, You can also find domestic domain names. If the result of Query Sohu is as follows. The program runs in Win98 and VB6.0. Out from the computer world

]

转载请注明原文地址:https://www.9cbs.com/read-86146.html

New Post(0)