Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shut down program

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
GB
Is it possible to shut down a program that is running from another program.

I have a program (not written by myself) that causes lots of errors when it quits. What I'd like to do is kill this from another program (that I will write) after it has done its job but before it tries to exit itself.

Is this possible and will it leave large chunks of memory still allocated for th program I've shut down?

I know the whle thing is a bodge but seeing as I dont have any source code for the original program I couldn't change it so it works properly.

Thanks

elziko
 
You might be able to use GetActiveWindow and CloseHandle to kill the program but you will probably have all kinds of memory leaks.
Colin Chevrier
colin.chevrier@ca.jdsuniphase.com

 
I finally got round to trying this out and I used this code:

Dim winHwnd As Long
Dim intRet As Integer
winHwnd = FindWindow(vbNullString, "VTPlus for Win/TV")
Debug.Print winHwnd
If winHwnd <> 0 Then
intRet = CloseHandle(winHwnd)
Debug.Print intRet
Else
MsgBox &quot;VTPlus for Win/TV is not open.&quot;, vbOKOnly, &quot;Info:&quot;
End If

Although I seem to be able to get the handle OK the CloseHandle function just returns a zero. (An error). I'm certain that the handle is OK.

Any advice?

Any alternatices to closehandle?

I now dont care about memory leaks because the computer will usually be restarted after this program has run anyway.

Many thanks

elziko
 
A *really* ugly method would be to force a system restart.

This url:
has exactly what you need - (I have no affiliation with these people, I found the software for a problem I needed to solve).
Then shell to shutdown and the PC will reboot - unless you are running Win9x with a DOS window open.

As I said, an ugly way of doing it, but sometimes you need to get dirty!
 
I'm afraid that doen't help me since I need to run another program to act on the data produced by the first program before the computer is shutdown.

I really need something to kill the application in its tracks as if I've closed the program from the task manager.

Thanks for your input though,

elziko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top