Solved

Need a way to auto. answer a msgbox

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now