Solved

Need a way to auto. answer a msgbox

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
VB 6.0 printer how to align 6 58
Adding to a VBA? 6 62
Excel Automation VBA 19 37
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now