並非虛構... (一笑之)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
作者:Chris Sells
譯者:榮耀
我的一個朋友在微軟源碼中意外發現瞭如下代碼:
//Function: RunCommandEx
//Synopsis: runs the given command in the current session, more robust
// than RunCommand
//Arguments: none
//Returns: S_OK if success
//History: October 3, 2000 - created [name withheld to protect the guilty]
HRESULT RunCommandEx(LPCWSTR szCmdLine)
{
DWORD dwTry = 0;
HRESULT hResult = S_OK;
//try run command 3 times at most
while (dwTry<4)
{
hResult = RunCommand(szCmdLine);
if (hResult!=E_FAIL)
{
//we succeeded
break;
}
dwTry++;
}
if (dwTry==4)
{
ATLTRACE(L"COuld start the command even we tried 4 times/n");
//譯註:或許Chris的本意是
//ATLTRACE(L"Couldn't start the command even we tried 4 times/n");
ASSERT(FALSE);
}
return hResult;
}
這並非我所指的強健,但也不錯...