這是一個非常簡單的示例,在網頁或其他平臺獲取程式中已經登陸的用戶,當然也可以是其他信息。 源碼 ...
這是一個非常簡單的示例,在網頁或其他平臺獲取程式中已經登陸的用戶,當然也可以是其他信息。
源碼
Imports DSAPI.網路.HTTP監聽_DSWebAPI Public Class Form1 Private WithEvents SV As New DSAPI.網路.HTTP監聽_DSWebAPI With {.綁定埠 = 83, .自定義首頁文件路徑 = ""} Private USERNAME As String = "" Private PASSWORD As String = "" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load SV.啟動監聽() End Sub Private Sub SV_收到客戶端請求(客戶端 As DSAPI.網路.HTTP監聽_DSWebAPI.WebAPI客戶端, 鍵值列表 As DSAPI.網路.HTTP監聽_DSWebAPI.鍵值列表, ByRef 返回信息 As String, ByRef 返回數據() As Byte) Handles SV.收到客戶端請求 If 鍵值列表 Is Nothing OrElse 鍵值列表.Count = 0 Then Exit Sub Dim 鍵值 As 鍵值 = 鍵值列表("user") If 鍵值 Is Nothing Then 返回信息 = "No" : Exit Sub '或返回一個登陸頁面 If USERNAME.Length = 0 Then 返回信息 = "當前沒有用戶登陸" Else 返回信息 = String.Concat("當前已登陸用戶:", USERNAME) End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click USERNAME = TextBox1.Text PASSWORD = TextBox2.Text End Sub End Class