Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal approach for storing INI-type settings and/or DB files on various Windows machines

OK, true confession first: Maybe it's just me, but sometimes "best practices for program settings" on Windows machines feels like it's changed more than Microsoft's data access strategies. I'm still running XP, and somewhere along the way just kind "glazed over" about where MS wanted me to store all my app's data, etc. I controlled all the machines I coded for, so it really didn't matter.

Now I'm writing apps for "in the wild," supporting Win98SE on up. I have to pay attention to all this again. :-\

For reasons having to do mostly with easy migration to new computers, I'm not a big fan of using the registry for app settings -- I prefer using INI files, and have some older INI components that I use for the task (Raize, usually). I'm open to suggestions to other third-party components, if they'll make this easier / less hassle.

Basically, I need to store app settings (like remembering option settings, etc).

I've read: Registry vs. INI file for storing user configurable application settings
Where to store program settings instead of HKEY_LOCAL_MACHINE?
Where should my win32 program keep its files?
Best place to store configuration files and log files on Windows for my program?

...so at least I'm not alone in this question... ; )
(w/apologies for what is somewhat of a repeat question, albeit from a slightly different angle).

It SOUNDS like I can just use %APPDATA%/MyProgram, and store all data there, BUT is this UNIVERSALLY TRUE across all Windows flavors from Win98SE on up? If not, what's the best approach, and when did that approach come into existence?

What I'm really looking for, honestly, is the easiest way to make this problem go away -- I just want one (if possible), simple, easy, reliable way to grab "My Program's Data Folder" in any and all instances. Will the above accomplish that?

like image 553
Jamo Avatar asked Dec 31 '22 03:12

Jamo


1 Answers

Head over to Making Delphi programs Vista-Ready and scroll down to the bottom for: "Where to save your application data?"

function GetRoamingUserAppDataPath : string; //works so long as people have at least IE 4. (and Win95 or better)

like image 62
Bob S Avatar answered Jan 01 '23 18:01

Bob S