By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,166 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,166 IT Pros & Developers. It's quick & easy.

First parameter to the FindWindow API

P: n/a
kd
Hi All,

I need to check whether an application is executing. I do not know the class
name of the application; however, I know the window caption of the
application. What would be the first parameter that I should be passing to
the FindWindow API, in order to check whether the application is executing?

Thanks.
kd
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"kd" <kd@discussions.microsoft.com> schrieb:
I need to check whether an application is executing. I do not know the
class
name of the application; however, I know the window caption of the
application. What would be the first parameter that I should be passing to
the FindWindow API, in order to check whether the application is
executing?


Simply pass 'vbNullString' to the first parameter and pass the window title
to the second parameter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
Just extending what Mr MVP said:

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

' Find Window passing the class name only
Dim intHandle As Integer = FindWindow("[Class Name Here]",
vbNullString)
' Show the handle in a messagebox
MessageBox.Show(intHandle, "Find Window Handle via class name")
' Find Window passing the Window caption only
Dim intHandle2 As Integer = FindWindow(vbNullString, "[Window
Caption Here]")
' Show the handle in a messagebox
MessageBox.Show(intHandle2, "Find Window Handle via Window caption")
Nov 21 '05 #3

P: n/a
Crouchie,

"Crouchie1998" <Cr**********@discussions.microsoft.com> schrieb:
Just extending what Mr MVP said:
:-)

I would be glad if you don't always call me "Mr MVP" :-). My name is
Herfried...
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal
lpClassName As String, ByVal lpWindowName As String) As Integer

' Find Window passing the class name only
Dim intHandle As Integer = FindWindow("[Class Name Here]",
vbNullString)


Although your code works, I'd use 'IntPtr' for the handle returned by
'FindWindow' instead of 'Integer'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.