2020年7月10日 星期五

vb.net 取得當前視窗的名稱 [Get Focus Windows name]

1
2
3
4
5
6
7
8
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function GetForegroundWindow Lib "user32" () As Long

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim lpString As String = New String(Chr(0), 255)
        Dim Ret As Integer = GetWindowText(GetForegroundWindow, lpString, 255)
        Me.Text = lpString
    End Sub

沒有留言:

張貼留言