OS dependant environment variables

Community Forums/General Help/OS dependant environment variables

Blitzplotter(Posted 2014) [#1]
Windows 7 (appears) to come with a number of environment variables padded out for the old coder to exploit.

Just because Microsoft has elected to stop supporting XP shortly, I was kinda hoping to code for those in the XP arena still. I used some environment vars within W7 to good effect, but XP borked at them - I'm slapping in some safety net malarky for said ENV vars now.

My question is - is there no need to establish environment variable for "C:\ProgramData\{Application}\thingy.ini" because XP might always have the ProgramData directory at a suffix of whatever drive the ProgramData directory hangs off?


xlsior(Posted 2014) [#2]
In general, it's dangerous to make assumptions regarding folder names -- even if it works right now, chances are that the next version of windows changes things around again and your program may stop working at that point.

Another thing to consider is that in non-English versions of windows, many of the system folder names are translated to the local language as well, and the absolute path may not exist under the name that you're expecting.

to do it -properly- you should query the windows API functions about the location of the system folders in question, which should map to the absolute path.

IIRC Brucey has a bah.volumes module that obtains a number of the relevant folders on the various operating systems.


BlitzSupport(Posted 2014) [#3]
There's this too:

http://www.blitzbasic.com/codearcs/codearcs.php?code=2815


Blitzplotter(Posted 2014) [#4]
Tried to err away from absolute path names - thanks for the feedback. I need to develop a robust environment variables searcher for both my B3D program and the Innosetup Script I use for installation.