Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to terminate a known app?

1 view
Skip to first unread message

JaimeP

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
I've got an app that I'd like to kill when my system starts up. If I
know what the name of the app is in task magager, how can I do this?
What API do I call? Any help would be appreciated.

Sent via Deja.com http://www.deja.com/
Before you buy.

jsed...@my-deja.com

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
You can do a SendMessage API call with WM_CLOSE (or WM_DESTROY, I
forget). You'll need the handle to the app though, but you can get
that with EnumWindows or FindWindow API.

Just curious, what app are you trying to kill? Can't you just tell it
not to launch at start up?

In article <85091t$dso$1...@nnrp1.deja.com>,

JaimeP

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to

Well, the program is an servey that is automatically being ran via NT
domain login stuff. I want to put something in my startup group that
will kill it off. hehe

In article <850b0c$fht$1...@nnrp1.deja.com>,

--
JaimeP

Edward Wasserman

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
This isn't really what you were looking for, but if you don't ever want
the app to run at startup and it isn't in your start folder, you just
need to remove it from your registry
This shows how to add programs, but you can use it to get rid of them as
well
--------------------------------------------------------
Launching Programs When Windows Starts (Windows 9x and NT)
You can automatically start programs whenever Windows lauches. If you
have programs automatically starting that you have not loaded then you
can remove them using this tip as well.

1. Open your registry and find the key below.
Key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
Data Type: REG_SZ
2. For each program you wish to start automatically create a new string
value using a descriptive name, and set the value of the string to the
program executable.

For example, to automatically start Notepad, add a new entry of
"Notepad"="c:\windows\notepad.exe".

Note: Remember to include the full path to the file, if the directory is
not included in your default search path.

If you're trying to remove a program and can not find it in the default
key, then additionally try these keys as well:

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce]

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\Userinit]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows]

Shabbir Darugar

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
I assume when you say "your system starts up" - you mean "your application
starts up". i.e. You want to kill an app (if it's running) as soon as your
program starts up. If so this should help.

I have used this technique to terminate an application who's Window Caption
I knew. (the caption was "Ticker"). If you don't know the caption of the app
(or if it varies) there are other ways - let me know.

Best of luck!

Shabbir

'============== Put the following code in a module =============='
' Note: Piece of code to modify in this module --- Mid(strWindowTitle, 1, 6)
= "Ticker"
' Remember to replace the word "Ticker" with the caption of the app you are
trying to terminate.
' Also make sure you replace the number 6 with the length of the caption. (6
is the length of word "Ticker")

Option Explicit

Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long,
ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd
As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As
Long
Dim lngRetVal As Long
Dim strWindowTitle As String * 100

Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&

' Getting window caption first.
lngRetVal = GetWindowText(hwnd, strWindowTitle, 100)

' If window caption matches, then go ahead and terminate app.
If Mid(strWindowTitle, 1, 6) = "Ticker" Then
' this code actualy terminates the other app.
hwnd = SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, NILL)
End If

EnumWindowsProc = 1 ' return value of 1 means continue enumeration
End Function
'======================= End =========================='

'== Put the following code where you want the other app to be terminated
==='
' (in your case you might want to put this in the Form Load event)
Dim varRetVal As Variant
varRetVal = EnumWindows(AddressOf EnumWindowsProc, 0)
'======================= End =========================='

JaimeP <alli...@my-deja.com> wrote in message
news:85091t$dso$1...@nnrp1.deja.com...

Paul Clement

unread,
Jan 6, 2000, 3:00:00 AM1/6/00
to
On Wed, 05 Jan 2000 20:20:31 GMT, JaimeP <alli...@my-deja.com> wrote:

¤ I've got an app that I'd like to kill when my system starts up. If I


¤ know what the name of the app is in task magager, how can I do this?
¤ What API do I call? Any help would be appreciated.

Take a look at the following MS KB article:

HOWTO: Programmatically Close a Separate Application
http://support.microsoft.com/support/kb/articles/Q176/3/91.ASP


Paul
~~~~
pcle...@ameritech.net

0 new messages