Solved

Stopping a running app from VB

Posted on 1998-10-09
4
146 Views
Last Modified: 2010-04-30
I need to stop and restart (reboot) another application from within my VB app. For example, 'myapp' needs to stop stop MS Word and then restart it. Does anyone know the best way to do this?

Thanks
0
Comment
Question by:joe_s
[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
4 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1439057
Get the HWND of the application, and send a close message :

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_CLOSE = &H10&


Call PostMessage(nHWND, WM_CLOSE, NULL, NULL)

0
 
LVL 14

Expert Comment

by:waty
ID: 1439058
To find the hwn of the application :

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


   nHwnd = FindWindow("Your Program", vbNullString)

0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1439059
Use "OpusApp" for word
0
 

Author Comment

by:joe_s
ID: 1439060
Thanks, That's just what I needed.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…

688 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