?? talkerservice.vb
字號:
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Threading
Imports System.Net.Sockets
Imports System.Windows.Forms
Class TalkerService
Public Shared endPoint As IPEndPoint
Public Shared client As Boolean
Public Shared Sub Main(ByVal args() As String)
'如果命令行參數符合要求,則運行該程序
If ParseArgs(args) Then
Dim talkerObj As New Talker(endPoint, client)
'實例化Talker類
Dim form As New frmTalker(talkerObj)
'實例化TalkForm類,并傳遞Talker對象
talkerObj.Start()
'啟動對象
Application.Run(form)
'運行程序
End If
End Sub
Private Shared Function ParseArgs _
(ByVal args() As String) As Boolean
'分析命令行參數
Try
If args.Length = 0 Then
client = False
endPoint = New IPEndPoint(IPAddress.Any, 5150) '
' 獲取IP地址
Return True
End If
If Not (args(0).ToCharArray()(0) = "/" Or _
args(0).ToCharArray()(0) = "-") Then
Return False
End If
Dim port As Integer
Select Case Char.ToUpper(args(0).ToCharArray()(1))
Case "L"c
port = 5150
If args.Length > 1 Then
port = Convert.ToInt32(args(1))
End If
endPoint = New IPEndPoint(IPAddress.Any, port)
client = False
Case "C"c
port = 5150
Dim address As String = "127.0.0.1"
client = True
If args.Length > 1 Then
address = args(1)
port = Convert.ToInt32(args(2))
End If
endPoint = New IPEndPoint _
(Dns.Resolve(address).AddressList(0), port)
Case Else
Return False
End Select
Catch
End Try
Return True
End Function
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -