Updated fix to work properly with _snprintf_s

* Modified first and second parameters to use `dwOutputLength` which
  is given to the function as an indicator of buffer size in bytes
  anyway.
* Check the return value of the function call to see if the result
  was a truncation, and if so, break from the current loop.

Realistically, truncation will not happen because the default windows
installation location folder name is very short.

Thanks @jvazquez-r7 for prodding me to validate this.