Use _putenv on Windows/MinGW

SetEnvironmentVariable apparently doesn't modify the same set of environment variables that getenv accesses. Therefore, this fix uses _putenv.