Code: Select all
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", EntryPoint:="FindWindowW")>
Public Shared Function FindWindowW(<MarshalAs(UnmanagedType.LPTStr)> ByVal lpClassName As String, <MarshalAs(UnmanagedType.LPTStr)> ByVal lpWindowName As String) As IntPtr
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim hWnd As IntPtr = FindWindowW("TheClassName", Nothing)
If hWnd <> IntPtr.Zero Then
'do whatever you need with the window handle....
End If
End Sub
End Class