qgetenv returns QByteArray, which has undefined encoding. We can't use this.

Replace it with GetEnvironmentVariableW and convert from the wide character encoding instead.
See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683188(v=vs.85).aspx