ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm creating a C++ project (based on Qt) and I'm about to read the configuration file of the project.
In *nix, the route would be something like /etc/projectname/projectname.rc or something like that... however, in Windows it could be "C:\Program Files\projectname\" or "C:\Archivos de programa\projectname\" (and others depending on the language) or the place where the user decided to place the file. Is there a way that this default location (program files, archivos de programa, etc, not considering user defined locations) can be gotten so I can make up the default route?
Typically, in a recent Windows system, the basic information would be in the registry. That information would include the location of the application and of it's "configuration file." Again, typically, configuration files are avoided in Windows, and the application preferences stored in the registry.
Older Windows systems used "<app_name>.ini" files stored in C:\Windows\, although, IIRC, XP uses %system_root%\%system_home\" and you could, in principle, store you configuration information there. If the information is user specific, and you anticipate multiple users, something like C:\Windows\<app_name)_<user_name>.ini might also work.
Note, please, that this is a Linux questions forum, and -- again, typically -- you will receive flack from some people offended by Windows questions.
I definitely don't want to go the windows registry route. So I'll probably stick with the ini files in c:\windows\blah blah
Second... I wanted to make sure I hadn't misread... and I didn't. Right on top of the Programming forum, I read: "Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game." So I guess Windows related questions are OK... aren't they? ;-) Anyway... I promise not to ask a lot about windows... The fact that I hate it is the most compelling reason not to bother myself thinking a lot about it. :-)
And third: I'm actually programming on linux.... but the system is intended to be working on linux/windows or wherever Qt is supported. I have a number of
In my commercial app, I stay away from the registry to the extent that is humanly possible (I do have to write a couple of things to it in order for it to work properly with windows).
I have created an etc subdirectory under my program's main install directory and this is where I place all configuration files. Aside from the fact that this keeps me away from that gawdawful registry, it will prove very helpful for my next version, which will be multi-platform (including Linux).
You can, I believe, use the symbolic name "%ProgramFilesDir%" in place of the C:\... name, which is usually more portable and not language specific. (That's from a "google," not actual usage by me.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.