   E_FAIL / S_OK
  I've been using E_FAIL / S_OK as mr preferred HRESULT's to return on failure/success. But I should probably use S_OK with S_FALSE...?Does anybody have a good resource regarding these codes? I should be getting the Petzold book soon...   
  Personally, I prefer TRUE/FALSE (or true/false) to the HRESULT method. In fact, an even better approach is to actually define constants (via an enum, if your language supports it) that properly describe the return values, instead of just an abstract "OK/not OK" thing.Even better, assuming the language supports it, don't use return codes at all.   ;Quote:Original post by discman1028I've been using E_FAIL / S_OK as mr preferred HRESULT's to return on failure/success. But I should probably use S_OK with S_FALSE...?Does anybody have a good resource regarding these codes? I should be getting the Petzold book soon...Definitely not. S_FALSE is a success code, E_FAIL is an error code. If you sue the SUCCEEDED and FAILED macros, S_FALSE will succeed, and E_FAIL won't. S_FALSE is usually used for "Not an error, but it didn't complete successfully".Still, I prefer true / false, and have a GetError() function that returns a std::string description. It's a matter of preference really.   ;  E_FAIL should basically be your last pick for an error code.  It basically means "something went wrong but I'm not going to tell you what".  Look in winerror.h, there are tons of possible error codes in there covering all sort of scenarios.  There's even a procedure to let you use app-specific HRESULT's.As someone else mentioned S_FALSE is not an error code, it's a success code.  It's for something like (say) a DoesFileExist API.  S_OK means "yes", S_FALSE means "no", E_INVALIDARG means "dude, I at least need a filename", E_ACCESSDENIED means "I can't tell you", E_FAIL means "uh, I dunno", etc.   ;  Good to know guys thanks... glad I didn't go to S_OK / S_FALSE and use the SUCCEEDED / FAILED macros. :)I'll either go bool or my own. MAYBE Windows's. Thanks all.   