这是我写的一个注册域名的一段代码片 想用C#写的,,自己用vb.net to c# 转一下 有什么不明白的,可以联系我,ssihc@163.com QQ:47400789 代码如下 Imports System.Runtime.InteropServicesImports System.NetImports System.Net.SocketsImports System.Text.RegularExpressionsImports System.XmlImports System.TextImports System.IOPublic Class epp Public _exit As Boolean = True Public _pws As String Public _regeditmesage As String Public _purveyor As String Public obj As Form1 Public Event epp_event(ByVal domain As String) <DllImport("libeay32.dll", EntryPoint:="BIO_new_socket", SetLastError:=True)> _ Public Shared Function BIO_new_socket(ByVal socket As IntPtr, ByVal flag As Integer) As IntPtr End Function <DllImport("libeay32.dll", EntryPoint:="OPENSSL_add_all_algorithms_noconf", SetLastError:=True)> _ Public Shared Sub OPENSSL_add_all_algorithms_noconf() End Sub <DllImport("ssleay32.dll", EntryPoint:="SSL_connect", SetLastError:=True)> _ Public Shared Function SSL_connect(ByVal sslSocket As IntPtr) As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_CTX_new", SetLastError:=True)> _ Public Shared Function SSL_CTX_new(ByVal ptr As IntPtr) As IntPtr End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_CTX_free", SetLastError:=True)> _ Public Shared Sub SSL_CTX_free(ByVal ssl As IntPtr) End Sub <DllImport("ssleay32.dll", EntryPoint:="SSL_get_error", SetLastError:=True)> _ Public Shared Function SSL_get_error(ByVal ssl As IntPtr, ByVal ret As Integer) As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_library_init", SetLastError:=True)> _ Public Shared Function SSL_library_init() As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_new", SetLastError:=True)> _ Public Shared Function SSL_new(ByVal ptr As IntPtr) As IntPtr End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_read", SetLastError:=True)> _ Public Shared Function SSL_read(ByVal ssl As IntPtr, ByVal buf() As Byte, ByVal num As Integer) As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_set_fd", SetLastError:=True)> _ Public Shared Sub SSL_set_fd(ByVal ssl As IntPtr, ByVal sd As IntPtr) End Sub <DllImport("ssleay32.dll", EntryPoint:="SSL_set_bio", SetLastError:=True)> _ Public Shared Sub SSL_set_bio(ByVal ssl As IntPtr, ByVal BioRbio As IntPtr, ByVal BioWbio As IntPtr) End Sub <DllImport("ssleay32.dll", EntryPoint:="SSL_shutdown", SetLastError:=True)> _ Public Shared Function SSL_shutdown(ByVal ssl As IntPtr) As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_write", SetLastError:=True)> _ Public Shared Function SSL_write(ByVal ssl As IntPtr, ByVal buf() As Byte, ByVal num As Integer) As Integer End Function <DllImport("ssleay32.dll", EntryPoint:="SSLv23_client_method", SetLastError:=True)> _ Public Shared Function SSLv23_client_method() As IntPtr End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_CTX_use_certificate_file", SetLastError:=True)> _ Public Shared Function SSL_CTX_use_certificate_file(ByVal ssl As IntPtr, ByVal file As String, ByVal n As Integer) As IntPtr End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_CTX_use_PrivateKey_file", SetLastError:=True)> _Public Shared Function SSL_CTX_use_PrivateKey_file(ByVal ssl As IntPtr, ByVal file As String, ByVal n As Integer) As IntPtr End Function <DllImport("ssleay32.dll", EntryPoint:="SSL_CTX_check_private_key", SetLastError:=True)> _Public Shared Function SSL_CTX_check_private_key(ByVal ssl As IntPtr) As IntPtr End Function Const SSL_FILETYPE_PEM = 1 Dim bReceived(4098) As Byte Dim numBytes As Integer Dim mySocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Dim epHost_cn As New IPEndPoint(Dns.GetHostByName("218.241.97.22").AddressList(0), 3000) ' random SSL-enforcing server for testing purposes Dim epHost_en As New IPEndPoint(Dns.GetHostByName("218.241.97.2").AddressList(0), 3121) ' random SSL-enforcing server for testing purposes Dim sslCtx As IntPtr Dim ssl_socket As IntPtr Private Function GeneralCode() As String 'general random value from 65(A) to 122(z) Dim pre1 As Byte Dim pre2 As Byte Dim value As Integer Dim value1 As Integer Randomize() ' Initialize random-number generator. 'A--Z pre1 = Int((122 - 97 + 1) * Rnd() + 97) pre2 = Int((122 - 97 + 1) * Rnd() + 97) value = Int((1000000 * Rnd()) + 1) value1 = Int((1000000 * Rnd()) + 1) Dim code As String code = Char.ToUpper(Convert.ToChar(pre1)) & Char.ToUpper(Convert.ToChar(pre2)) & value.ToString & value1.ToString Return code End Function