473,830 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

First parameter to the FindWindow API

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
3 3107
"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
Just extending what Mr MVP said:

Private Declare Function FindWindow Lib "user32" Alias "FindWindow A" (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(vbNu llString, "[Window
Caption Here]")
' Show the handle in a messagebox
MessageBox.Show (intHandle2, "Find Window Handle via Window caption")
Nov 21 '05 #3
Crouchie,

"Crouchie19 98" <Cr**********@d iscussions.micr osoft.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 "FindWindow A"
(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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1632
by: James Hu | last post by:
Hi, For the simple code: from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello App") frame.Show(true)
5
3181
by: Ronny Sigo | last post by:
Hello all, I try to open and close a webpage (when timer ticks) The problem is that it won't close ... Can anybody see what I am doing wrong? I'll paste the code here ... Any help very much appreciated .... Thanks Ronny Declarations: Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal
17
3076
by: lauren quantrell | last post by:
I have an Access application with the name: MyAppName® It has the "®" symbol (ChrW$(&H00AE)) at the end of it. If I remane the application without the "®" symbol, I can use FindWindow to close the application, but with the "®" symbol it doesn't. Unfortunaetley this app is already distributed as MyAppName® and I cannot change it. I have tried: hwnd = FindWindow(vbNullString, "myAppName" & ChrW$(&H00AE)) But it won't work. Yikes.
4
2913
by: Olex Malko | last post by:
How to manage FindWindow() function working properly in ASP.NET application? In Windows Forms application it works fine. But in ASP.NET it returns NULL :( Probalby this is because of different context. Something like IIS is ran under other account or some services cannot interact with desktop. What exactly should be done to have it working? Thank you!
0
558
by: TonyG | last post by:
I need to send a message to a window in another application. The name of the window is known at design time and set in the constant App2_MONITOR_CAPTION. The message is defined as X_GenerateEvent. The following VB6 code works. Is this possible in C# ? Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SendMessage Lib...
5
7058
by: victor | last post by:
Help .... This is my situation: I've made two apps, a Managed C# and an Unmanaged MFC. The C# app communicates with the MFC-app via (Win32-API) PostMessage, done with the P/Invoke method. One of the activities is "FindWindow". Everything works fine. Until ...: I needed the same procedure within another context: now I need to communicate the C# with a web service (dll) running somewhere on a Server machine. This doesnot work anymore!
0
1554
by: Jim S | last post by:
Is looping FindWindow() ok? We have a simple little c# 2.0 app that’s sole purpose is to look for a dialog box from another app to pop up and then click it’s OK button. To do this we use a form with a timer control and some unmanaged code. The app works perfectly in test but I’m concerned about long term problems/leaks caused by frequent FindWindow calls (10 per second)? Although the popups might only occur 50-100 times a day,...
1
4310
by: musai | last post by:
Hi Members how to use findwindow API for outlook application let us example For excel we use to find excel FindWindow("XLMAIN", vbNullString)
2
7432
by: MegaOctet | last post by:
Hello, Here is my script import win32gui as w HWND= w.FindWindow("Document - WordPad",None) and here is the traceback: Traceback (most recent call last): File "C:\Python26\essai1.py", line 30, in <module>
0
9641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10769
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10520
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10196
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5775
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.