Solved

Need a way to auto. answer a msgbox

Posted on 2004-09-07
3
260 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 - Convert HH:MM into Decimal 8 77
How to make an ADE file by code? 11 111
Added a column screws up code 5 78
backup program with robocopy 6 92
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

752 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