[RE-SOLVED]:Registry on Windows INI files on other platforms

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

[RE-SOLVED]:Registry on Windows INI files on other platforms

Post by ONEEYEMAN »

Hi, ALL,
If I want to read the Registry on Windows, but want to make it work on other platform. I have to use wxRegKey class, or I could do it through the wxConfigBase classes?
Problem is: when I look at the example of wxCommand Base I didn't seeanything related to the registry. I don't know what registry keys will be read and everything.

Could somebody clarify tha, please?

Thank you in advance
Last edited by ONEEYEMAN on Mon Aug 15, 2005 4:46 am, edited 1 time in total.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

wxRegKey is as far as I know, windows only.

USe wxConfig for your configuration. It will automatically save in the registry per default under windows, and for linux I believe it will go to ~/.appname as configuration.

You don't have to deal with what is where, the classes that are created by wxConfig wil do that for you..

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

Thank you for the fast reply, Jorg.
On Linux/Mac it's pretty much understandable. I create the .INI file, create it myself, the read the values from there.
But what about Registry? Which key the info will be stored in? Can I set the path to that key?

Thank you.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

Hi,

Forget about INI files and registry. When using wxConfig you allow yourself to not worry about where it is all put.

In windows it will be in /HKEY_CURRENT_USER/Software/YourVendor/YourApp

In Linux it will be in a kind of ini file.

In both cases, simply use thw wxConfig classes only, will abstract you from handling the config yourself.

You can however force to stay wih e.g. wxFileConfig. This will on both platforms write to an ini file you specify. The problem then is that INI files in Linux are only writable in the HOME dir of the average user. So letting wxConfig handle that, makes life a lot easier.

Read about it here:

http://www.wxwidgets.org/manuals/2.6.0/ ... configbase

http://www.wxwidgets.org/manuals/2.6.0/ ... igoverview
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

jorg.... its manuals/2.6.1/... update your bookmarks :wink:

PS for all you firefox users, you can search the wx docs using your searchbar!

make a bookmark with any title, for the address use http://wxwidgets.org/manuals/2.6.1/wx_%s.html, and in the field 'keyword' type in 'wx' or whatever you want... to search the docs, just type in wx [classname] in your addressbar... and you will be brought to the page with the class name...

if it doesnt exist, it will just be a pesky 404... haha
NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Post by NinjaNL »

lowjoel wrote:PS for all you firefox users, you can search the wx docs using your searchbar!
GREAT TIP!!
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

more than welcome ninjanl ;) i got a whole mouthful of them haha... some to google, others to msdn, yet more to encarta... haha if u can submit a form using GET u can use the address bar...
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

Thank you for the reply, guys.
Like I asked in the previous post, am I allowed to change the Registry path to "HKEY_CURRENT_USER\smth, or is it possible only by tweaking he library code?

Thank you.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

It is not recommended to put settings outside the preferred area such as; HKEY_CURRENT_USER/Software/Yourapp

If you really need to read/write from the other parts, you can use wxRegKey directly.

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

A) wxRegKey IS windows-only (if you MUST use it ifdef with __WXMSW__)
B) Use wxFileConfig directly if you want to have INI files on all platforms
C) Try not to write outside MS-defined registry keys that wx uses...
[Mostly retired moderator, still check in to clean up some stuff]
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

Thank you for the reply, guys.
It is not my intention to use the .INI files on every single platform. On Windows I want to use Registry. And according to Jorg, I am stuck with only one key.
2Ryan: What keys are used by wxWidgets on Windows? I thought it's only for the demo program...

Thank you.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

2Jorg: Are you sure it's HKEY_CURRENT_USER, and not HKEY_LOCAL_MACHINE? 'Cause I just read the HKEY_LOCAL_MACHINE value, whereas HKEY_CURRENT_USER doesn't have the value... :)

Thank you.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

That would be a bad case because not every user on a windows machine can be an adminstrator. HKCU/Software/App should be used for settings, and HKLM/Software/App could be used for global settings set once of the installer.

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

OK, got it. It reads both but they are for the different purpose.

Thank you.
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

ONEEYEMAN wrote:OK, got it. It reads both but they are for the different purpose.

Thank you.
Please assign answers :).
[Mostly retired moderator, still check in to clean up some stuff]
Post Reply