GetEnv() Troubles

Monkey Forums/Monkey Beginners/GetEnv() Troubles

blueFire(Posted 2015) [#1]
I am trying to get the location of a folder contained in an environment variable (specifically the Music folder on windows). I am using the simple code produced below and testing it on Windows 8 (with the glfw2 target) but I cannot get the folder location.




impixi(Posted 2015) [#2]
There may not be a specific environment label for obtaining the current user's music folder through Monkey's GetEnv() function. The following will return the *default* Windows 8 music folder location:



But the user may have changed the default.

It may be necessary to wrap the SHGetKnownFolderPath() function through c++ for a "tidier" way. (pass it FOLDERID_Music)

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx

I could be wrong...


blueFire(Posted 2015) [#3]
I tried using GetEnv("USERPROFILE") + "\Music" and discovered it works for windows 8.1. I will have to test it to see if it works for older windows operating systems.

Thanks for the help.

Jason


ImmutableOctet(SKNG)(Posted 2015) [#4]
I seriously doubt it will work for XP (Unless Microsoft made a forward compatibility thing that would allow this to happen, but it's not like anyone's XP code would do this). That should work for every version of Windows post XP, though. Vista and onward use "%user%", but for XP and earlier, it's "Documents and Settings". Supposedly there's some compatibility stuff for XP programs using that folder, though. I'd recommend just using the Windows API for this. The only problem is, you'd be using Vista functionality, so you'd be limiting your application, anyway. I'd say you should use both, and simply check the Windows version on runtime. But, checking the Windows version also could be problematic (Thanks to Windows 8), so I'll leave you to figure that one out.

Also realize that XP is unsupported by even Microsoft. Not to mention old XP machines that could run OpenGL well enough could be running Vista and onward. It's kind of like the SSE2 argument: "We all have x64 processors, why not use SSE2, even for 32-bit executables?".


blueFire(Posted 2015) [#5]
I will look into checking the version of windows and customizing it for XP. I only do this because I still have four older computers that still run XP and I have no intention of upgrading them. If I am still using computers on XP I know others are.

Jason


impixi(Posted 2015) [#6]
In your OS run a "command prompt" and type:
set

A list of environment variables and their settings will be displayed. These are accessible to Monkey's GetEnv() and SetEnv() functions.
IIRC, XP stores music in a "My Music" folder off the user's profile somewhere. You *may* be able to mine enough information from the environment variables to fudge an OS check too... or not. Good luck. :)


impixi(Posted 2015) [#7]
This works for me for Windows 8.1 (Monkey Pro V82b, MinGW 4.8.1)

utils.cpp


test.monkey


Might work for XP...