Solved

Get Handle by Class Name

Posted on 2011-03-07
2
830 Views
Last Modified: 2012-06-27
I'm new to VB.NET
How do you get the hWnd of a external application by Class Name
Example:
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.
0
Comment
Question by:PhilChapmanJr
2 Comments
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35058319
Hi,

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)
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 35062847
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now