Solved

Need a way to auto. answer a msgbox

Posted on 2004-09-07
3
262 Views
Last Modified: 2006-11-17
hello again all, Im writing a program that interacts with professional software to fix an error we are experiencing with the  current version.  My fix calls the FindWindow function in combination with Sendmessage to close a window given its specific application handle.  The problem is, while running this fix I discovered that the professional software I am trying to close through my "fix" requires secondary close confirmation via a popup window upon termination.  I could theoretically use the same process to close this new window as I did the origional, unfortunately the handle name does not appear in the task list.  Does anyone out there know how to either i, write an intstruction that tells the popup window to automatically click "Yes" to close the app or ii, find a way to address this window without knowing its name?  The problem is I have multiple (sometimes) other processes running in the background that would cause me other problems if they were accidentally closed by a close-all type function.  
P.S. I should mention that this fix of mine is written in VB6

 here is the FindWindow and Sendmessage 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

Function CloseApp()
Dim m As Long
    m = FindWindow(vbNullString, ApplicationName)
    SendMessage m, WM_CLOSE, 0, 0
End Function


Thanks in advance for any help/advice received
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
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 250 total points
ID: 12001504
This sample may be what you are looking for:

"Safely Shut Down a Running Application"
http://www.thescarms.com/vbasic/StopProcess.asp
0
 
LVL 2

Author Comment

by:gwosgood
ID: 12006591
does anyone know if WM_DESTROY releases the applications resources upon execution?
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12006921
It's up to the application to free memory objects and tidy up before terminating.  This is usually done in the WM_DESTROY message handler.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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
Course of the Month6 days, 11 hours left to enroll

623 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