TerminateProcess

想在当前进程中终止另一个进程,可以使用这个TerminateProcess函数。

This function terminates the specified process and all of its threads.

BOOL TerminateProcess(
HANDLE hProcess,
DWORD uExitCode
);
Parameters
hProcess
[in] Handle to the process to terminate.
uExitCode
[in] Specifies the exit code for the process and for all threads terminated as a result of this call.

To retrieve the process's exit value, use the GetExitCodeProcess function.

To retrieve a thread's exit value, use the GetExitCodeThread function.

Return Values

Nonzero indicates success.

Zero indicates failure.

To get extended error information, call GetLastError.

Remarks

This function is used to unconditionally cause a process to exit.

Use this function only in extreme circumstances.

This function causes all threads within a process to terminate, causes a process to exit, and notifies each DLL that the process is terminating.
这个进程有很多弊端(可能会导致处理进程结束工作的函数没有被执行完),一步不推荐使用。

The following list shows what occurs when a process is terminated:

  1. All object handles opened by the process are closed.
  2. All threads in the process terminate their execution.
  3. The state of the process object becomes signaled, satisfying threads waiting for the process to terminate.
  4. The states of all threads of the process become signaled, satisfying threads waiting for the threads to terminate.
  5. The termination status of the process changes from STILL_ACTIVE to the exit value of the process.

Terminating a process does not necessarily remove the process object from the system.

A process object is deleted when the last handle to the process is closed.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值