Solved

Stopping a running app from VB

Posted on 1998-10-09
4
140 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

705 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

18 Experts available now in Live!

Get 1:1 Help Now