November 27, 2001 fun

I am not making this up…

A friend of mine stumbled over this in the Microsoft source code:

//  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");
		ASSERT(FALSE);
	}
	return hResult;
}

That’s not quite my definition of robust, but oh well…

Tue 11/27/2001 3:52 PM