Code fixes

Various code fixes, mostly discovered by MSVC code static analyzer .
No, just some code > 0.
Codes in your link are mostly for GetLastError().
Application commonly use their specific return codes.