ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Kill a process - Could someone check this code for me (https://www.excelbanter.com/excel-programming/361042-kill-process-could-someone-check-code-me.html)

ina

Kill a process - Could someone check this code for me
 
Hello All,

I have a code that close a process. Could someone check this out for
me.


Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long



Sub ExitPLaunch()
Dim TaskID As Long
Dim hProc As Long
Dim lExitCode As Long
Dim ACCESS_TYPE
Dim STILL_ACTIVE


ACCESS_TYPE = &H400
STILL_ACTIVE = &H103


' Shell the task
TaskID = Shell("C:\program files\PLaunch\PLaunch.EXE, 1)


On Error Resume Next


' Get the process handle
hProc = OpenProcess(ACCESS_TYPE, False, TaskID)

On Error GoTo 0
Application.StatusBar = "Waiting for Packhedge application to
finish"
Do
GetExitCodeProcess hProc, lExitCode
DoEvents
Loop While lExitCode = STILL_ACTIVE


' Ouffa is Finshed
End Sub


Jim Rech

Kill a process - Could someone check this code for me
 
This code doesn't kill a process. It shells to the EXE and waits for it to
terminate, or be terminated externally, and then the macro continues.

--
Jim
"ina" wrote in message
ups.com...
| Hello All,
|
| I have a code that close a process. Could someone check this out for
| me.
|
|
| Declare Function GetExitCodeProcess Lib "kernel32" _
| (ByVal hProcess As Long, _
| lpExitCode As Long) As Long
|
|
|
| Sub ExitPLaunch()
| Dim TaskID As Long
| Dim hProc As Long
| Dim lExitCode As Long
| Dim ACCESS_TYPE
| Dim STILL_ACTIVE
|
|
| ACCESS_TYPE = &H400
| STILL_ACTIVE = &H103
|
|
| ' Shell the task
| TaskID = Shell("C:\program files\PLaunch\PLaunch.EXE, 1)
|
|
| On Error Resume Next
|
|
| ' Get the process handle
| hProc = OpenProcess(ACCESS_TYPE, False, TaskID)
|
| On Error GoTo 0
| Application.StatusBar = "Waiting for Packhedge application to
| finish"
| Do
| GetExitCodeProcess hProc, lExitCode
| DoEvents
| Loop While lExitCode = STILL_ACTIVE
|
|
| ' Ouffa is Finshed
| End Sub
|



ina

Kill a process - Could someone check this code for me
 
Ok for kill a process I need only to close the process if it is
running. that is all



All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com