kolistivra
asked on
killing a process
i would like to kill a process and i've tried many codes for this. most of the codes work properly for most programs BUT none of them was successful with notepad. open notepad and write something in it, and try to kill it. notepad will ask you if you want to save changes. i don't want such message, it should be closed without anything like most programs. i would like to be able to close any program i want without any message or something..
thanks in advance...
thanks in advance...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i will split points but before,
idle mind, can you also write a code for finding the "pid" of any program ?
EDDKT, i didn't understand your code much but it works fine, can you explain it a bit?
thanks
idle mind, can you also write a code for finding the "pid" of any program ?
EDDKT, i didn't understand your code much but it works fine, can you explain it a bit?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess _
As Long, ByVal uExitCode As Long) As Long
Private pid As Long
Private Sub Command1_Click()
pid = Shell("notepad.exe", vbNormalFocus)
End Sub
Private Sub Command2_Click()
Dim lngProcess As Long
If pid <> 0 Then
lngProcess = OpenProcess(PROCESS_ALL_AC
If lngProcess <> 0 Then
Call TerminateProcess(lngProces
End If
End If
End Sub