Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

closing apps

Posted on 2001-07-08
3
Medium Priority
?
168 Views
Last Modified: 2012-05-04
wonmdering what api to call in order to close all running apps?
thanks
0
Comment
Question by:cybermoonlight
[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
3 Comments
 
LVL 7

Accepted Solution

by:
q2eddie earned 400 total points
ID: 6263306
Hi, cybermoonlight.

#Links
1. "Enumerate Top Level Windows"
http://www.thescarms.com/VBasic/EnumWindows.asp

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

Bye. -e2
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6263310
Here are some things to look at:

http://www.freevbcode.com/ShowCode.Asp?ID=2781

http://www.vbapi.com/ref/w/wm_close.html

http://www.vbapi.com/ref/d/destroywindow.html

http://www.vbweb.co.uk/show.asp?id=146

They either kill a process, or a window (close / destroy).



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

Call SendMessage(hWnd, WM_CLOSE, 0, 0)

Where hWnd is the handle of the window to close.


http://www.mvps.org/vbnet/index.html?code/subclass/shellnotifybasic.htm

That link will show how to enumerate all windows and child windows.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6263450
Hi cybermoonlight,

Here is another samples:

'Close an application using the API.

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10
Private Sub cmdClose_Click()
   Dim winHwnd As Long
   Dim RetVal As Long
   winHwnd = FindWindow(vbNullString, Text1.Text)
   Debug.Print winHwnd
   If winHwnd <> 0 Then
       RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
       If RetVal = 0 Then
           MsgBox "Error posting message."
       End If
   Else
       MsgBox Text1.Text + " is not open."
   End If
End Sub
______________________________________________

Obtaining a List of Running Processes:

http://www.mvps.org/vbnet/code/system/toolhelpprocesses.htm

Compare your exe path with the processes running.

______________________________________________

Useful links:

http://www.mvps.org/vbnet/faq/main/getmodulehandle.htm

http://www.mvps.org/vbnet/code/system/toolhelpprocesses.htm

http://www.mvps.org/vbnet/faq/main/getexitcodeprocess.htm

http://www.mvps.org/vbnet/faq/main/getmoduleusage.htm

'Hope will help.

0

Featured Post

Technology Partners: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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

609 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