I believe the correct way under Windows is to use the API rather than the environment variable. I did have some code somewhere that did that, but I can't find it right now.