Get Handle by Class Name

I'm new to VB.NET
How do you get the hWnd of a external application by Class Name
MSBLClass is the Class Name of Windows Messenger
Notepad is the Class Name of Notepad
tSkMainForm is the Class Name of Skype

Thanks for you help.
Phil ChapmanAsked:
Who is Participating?
gamarrojgqConnect With a Mentor Commented:

You can use FindWindow, you have to declare this function first

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal ByVallpClassName As String, ByVal lpWindowName As String) As Integer

After that use this code get the hWnd

        Dim hWnd As Integer
        hWnd = FindWindow("Notepad", vbNullString)
        MsgBox("NOTEPAD: " & hWnd)
Phil ChapmanAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.