کد وی بی
هر پنجره ای فعال باشه عنوانش رو توی لیبل نشون میده
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Namespace WindowsFormsApplication1
Partial Public Class Form1
Inherits Form
' Declare external functions.
<DllImport("user32.dll")> _
Private Shared Function GetForegroundWindow() As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function GetWindowText(ByVal hWnd As IntPtr, ByVal text As StringBuilder, ByVal count As Integer) As Integer
End Function
Public Sub New()
InitializeComponent()
End Sub
Private Sub tmrRefresh_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles tmrRefresh.Tick
Dim chars As Integer = 256
Dim buff As New StringBuilder(chars)
' Obtain the handle of the active window.
Dim handle As IntPtr = GetForegroundWindow()
' Update the controls.
If GetWindowText(handle, buff, chars) > 0 Then
lblCaption.Text = buff.ToString()
lblHandle.Text = handle.ToString()
If handle = Me.Handle Then
lblCurrent.Text = "True"
Else
lblCurrent.Text = "False"
End If
End If
End Sub
End Class
End Namespace