Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem Closing an Application

Posted on 2004-08-18
8
Medium Priority
?
224 Views
Last Modified: 2010-05-18
Hello all, I am having a small problem trying to close an application through a program.  The application I am trying to close is called ColdBuild.exe.  Here is my code:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10

Private Sub cmdCloseApp_Click()
Dim m As Long
m = FindWindow(vbNullString, "ColdBuild")
SendMessage m, WM_CLOSE, 0, 0
End
End Sub

The problem is, this button ends up closing _my_ application and leaves the ColdBuild application open.  Any suggestions on how to remedy this?
0
Comment
Question by:gwosgood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11835197
Try sending a WM_QUIT message instead.
0
 
LVL 2

Author Comment

by:gwosgood
ID: 11835209
how do i declare that?
i.e. to declare WM_CLOSE,
Private Const WM_CLOSE = &H10
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 11835212
Is "ColdBuild" the window caption on the ColdBuild.exe app? It's not the caption on your form is it?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Author Comment

by:gwosgood
ID: 11835228
no, coldbuild is the title of the coldbuild application.  MY application caption is PSWFIX
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11835252
Private Const WM_QUIT = &H12
0
 
LVL 2

Author Comment

by:gwosgood
ID: 11835279
ok carl tawn, i used your new WM_QUIT suggestion and believe it or not, my application still closes instead of the intended ColdBuild
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 11835310
Your app is exiting because of the "End" statement after your call to SendMessage, rather than because of the SendMessage
0
 
LVL 2

Author Comment

by:gwosgood
ID: 11835343
d@mn, your right carl tawn ;)
appreciate the help
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 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