TerminateProcess ExitCode

I am trying to better understand some of the process APIs, namely GetExitCodeProcess and TerminateProcess. I found some code examples on the Internet, but not quite the explanation I'm looking for.

I understand that this will give me the process exit code.

lResult = GetExitCodeProcess(hProcess, lExitCode)

And this will complete the process

lResult = TerminateProcess(hProcess, lExitCode)

However, it seems that this last parameter of the exit code does not have to be the exit code received in the first line. In fact, I came across a few examples where it 0was replaced by an exit code.

lResult = TerminateProcess(hProcess, 0)

I thought lExitCode is the specific value that I should have provided to the TerminateProcess function, but apparently this is not the case - it seems that almost any number will work. Can someone give me an explanation on this?

+4
2

, , , TerminateProcess(). . Windows , . - , GetExitCodeProcess().

, TerminateProcess(), . , , . , 0 , , 1, , 2, , .. , , .

lResult = GetExitCodeProcess(hProcess, lExitCode)

lExitCode - , .

lResult = TerminateProcess(hProcess, lExitCode)

lExitCode , , lExitCode, . , , :

lExitCode = 0
lResult = TerminateProcess(hProcess, lExitCode)

lResult = TerminateProcess(hProcess, 0)
+3

Excel :

1)

enter image description here

2) ()

enter image description here

,

... TerminateProcess . , (DLL) , , TerminateProcess, ExitProcess...

...

: MSDN: Windows β†’ Dev Center-Desktop β†’ TerminateProcess

,

Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

(ByRef)

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

/

, . , . , GetLastError

(Visual Basic: err.LastDllError GetLastError)

: MSDN: TerminateProcess, GetExitCodeProcess , GetLastError

+4

All Articles