Fix some signed/unsigned mismatches (/W4 warnings).
Fix the remaining /W4 C4510 and C4610 warnings.
Fix the /W4 C4701 warnings: using potentially uninitialized local variable.
Use C++ style enum and struct declarations in C++ code.
Update SetThreadName based on the latest version available on MSDN.