Check return value.

Fixes CID #1109591, #1084350
Fix uninitialized class members.

Fixes CID #966364, #966344, #966315, #966315, #966347, #966319, #966314,
 #966313, #966280
Fix the /W4 C4245 warnings: signed/unsigned mismatch.
AppSettings: Move some backward compatibility code to UpdateSettings()