我有一段代码:
HANDLE hProcess;
DWORD dwExitCode;
DWORD dwDelay;
while (GetExitCodeProcess(hProcess, &dwExitCode))
{
if (STILL_ACTIVE == dwExitCode)
{
Sleep(dwDelay);
}
else
{
strMsg.Format("Process completed with exit code %d", dwExitCode);
LogComment(strMsg);
return;
}
}
dwExitCode = GetLastError();
strMsg.Format("Error %d getting exit code.", dwExitCode);
LogComment(strMsg)
这行得通吗?我的问题基本上是,如果在调用函数以获取while
循环表达式时出错,它会跳出该循环并让我捕获错误吗?还是我需要为此设置类似try...catch
块的东西?