I'm writing a Windows console application in C++ and would like to return zero on success and a meaningful error code on failure (i.e., S_OK
should return 0, and E_OUTOFMEMORY
should return a different return value than E_FAIL
and so on). Is the following an okay approach?:
int wmain(int argc, wchar_t *argv[])
{
HRESULT hr = DoSomething();
return (int) hr;
}
Or is there a better way? Maybe a standard Win32 API function or macro that I'm forgetting or failing to find?