若已知进程HANDLE,怎么判断进程是否已经结束?

tonybaobao 2004-08-23 04:13:04
我用ShellExecuteEx获得了HANDEL,但是我用什么API可以得知该进程已经执行完毕?因为我要在该进程完毕后才能进行一些处理.谢谢.
...全文
245 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jozu 2004-08-23
  • 打赏
  • 举报
回复
嘿嘿,这叫什么意思?我的回答不准确么?居然没有分?搞不懂怎么回事
jozu 2004-08-23
  • 打赏
  • 举报
回复
WaitForSingleObject(hYourProcess, INIFINATE);
返回的时候hYourProcess就是结束状态
tonybaobao 2004-08-23
  • 打赏
  • 举报
回复
谢谢各位,我等会儿试试看.
chqu18 2004-08-23
  • 打赏
  • 举报
回复
好象用WaitForSingleObject()来等待线程句柄的返回吧
msdn_user 2004-08-23
  • 打赏
  • 举报
回复
GetExitCodeProcess
The GetExitCodeProcess function retrieves the termination status of the specified process.

BOOL GetExitCodeProcess(
HANDLE hProcess, // handle to the process
LPDWORD lpExitCode // termination status
);
Parameters
hProcess
[in] Handle to the process.
Windows NT/2000 or later: The handle must have PROCESS_QUERY_INFORMATION access. For more information, see Process Security and Access Rights.

lpExitCode
[out] Pointer to a variable to receive the process termination status.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
If the specified process has not terminated, the termination status returned is STILL_ACTIVE. If the process has terminated, the termination status returned may be one of the following:

The exit value specified in the ExitProcess or TerminateProcess function.
The return value from the main or WinMain function of the process.
The exception value for an unhandled exception that caused the process to terminate.
DentistryDoctor 2004-08-23
  • 打赏
  • 举报
回复
WaitForSingleObject
or
GetExitCodeProcess
tonybaobao 2004-08-23
  • 打赏
  • 举报
回复
我也知道有这么一个API,但是不知道怎么用.我用过了,可是似乎没法判断.谁能给个例子看看.
jozu 2004-08-23
  • 打赏
  • 举报
回复
WaitForSingleObject

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧