|
-
Aug 29th, 2000, 01:52 AM
#1
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Aug 29th, 2000, 02:03 AM
#2
I did see this program that deleted programs that were actually running.
Don't know how it did it, but here's something that'll work.
If you know the exe, here's how to close it:
Code:
Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * MAX_PATH
End Type
Public Function KillApp(myName As String) As Boolean
Const PROCESS_ALL_ACCESS = 0
Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapshot As Long
Dim szExename As String
Dim exitCode As Long
Dim myProcess As Long
Dim AppKill As Boolean
Dim appCount As Integer
Dim i As Integer
On Local Error GoTo Finish
appCount = 0
Const TH32CS_SNAPPROCESS As Long = 2&
uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapshot, uProcess)
Do While rProcessFound
i = InStr(1, uProcess.szexeFile, Chr(0))
szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
If Right$(szExename, Len(myName)) = LCase$(myName) Then
KillApp = True
appCount = appCount + 1
myProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
AppKill = TerminateProcess(myProcess, exitCode)
Call CloseHandle(myProcess)
End If
rProcessFound = ProcessNext(hSnapshot, uProcess)
Loop
Call CloseHandle(hSnapshot)
Finish:
End Function
Usage:
Call KillApp("C:\program.exe")
And then you can delete it:
Code:
Kill ("C:\program.exe")
-
Aug 29th, 2000, 02:04 AM
#3
Hyperactive Member
Depending on what file it is... txt opened with notepad can be deleted.. when it's opened with word you can't..
Uhmmm can you shorten you signature a little? It's almost one full screen (17" 1025x768) which is a bit way tooooooooooo big....
-
Aug 29th, 2000, 02:06 AM
#4
Thread Starter
Frenzied Member
I try to post my signature only once per thread
-
Aug 29th, 2000, 02:07 AM
#5
Thread Starter
Frenzied Member
o yea, thanks bill, I mean Matt Gates (just pulling your leg)
NXSupport - Your one-stop source for computer help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|