Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Nov 18, 2019 12:57 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Registry Entries - Windows 7
PostPosted: Thu Nov 24, 2011 5:42 am 
Offline

Joined: Mon Jun 06, 2011 6:11 am
Posts: 15
Location: Salford, UK
I want my application to be able to write and read registry entries relating to user preferences/registration details that are generated as the program is used.

How do I go about this without having to run my program as an Administrator which seems the only way it can gain access to the Registry under Windows 7?

Sorry to sound a bit vague but I've never ventured in to the realms of the Registry before and am getting very confused.


Top
 Profile  
Reply with quote  
 Post subject: Re: Registry Entries - Windows 7
PostPosted: Fri Nov 25, 2011 8:37 am 
Offline

Joined: Sat Mar 12, 2011 9:18 am
Posts: 71
I haven't play much with the registry but if you only want to save your applications preferences, why not save them to a file on disk in the specialfolder.preferences place ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Registry Entries - Windows 7
PostPosted: Fri Nov 25, 2011 9:43 am 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Store all your settings in the HKEY_CURRENT_USER hive rather than in HKEY_LOCAL_MACHINE to avoid permissions issues.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Registry Entries - Windows 7
PostPosted: Tue Jan 24, 2012 11:47 am 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
To be a little more in detail, I did :

In the Open event of the main Window. The "IF" Condition will make shure the registry values are initially created only on first start of the software.
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Your_Software\",true)
if custRegItem.value("once") = 0 then
custRegItem.Value("value1") = "whatever"
custRegItem.Value("value2") = "whatever2"
custRegItem.value("once") = 1
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Blade Calc Flex\Yoursoftware_setting\",true)
custRegItem.Value("Sort") = Number
custRegItem.Value("count") = Number
end if


Then later to read the registry:
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Your_Software\")
whatever_variable = custregitem.value("value1")
whatever2_variable = custregitem.value("value2")
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Yoursoftware_setting\")
number1_variable = custRegItem.Value("Sort")
number2_variable= custRegItem.Value("count")


Writing to the registry while the software runs:
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Your_Software\")
custregitem.value("value1") = whatever_variable
custregitem.value("value2") = whatever2_variable
custRegItem = New RegistryItem("HKEY_CURRENT_USER\SOFTWARE\Yoursoftware_setting\")
custRegItem.Value("Sort") = number1_variable
custRegItem.Value("count") = number2_variable


I use the declare everytime before using the registry
Dim custRegItem As RegistryItem


So this works for me in XP, Vista and 7 without any popup that yells for any rights :D
So using the Registry is like setting a path and reading/writing values to that path.

Greets, Schnitzelbrain

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
 Post subject: Re: Registry Entries - Windows 7
PostPosted: Wed Feb 01, 2012 4:06 pm 
Offline

Joined: Mon Jun 06, 2011 6:11 am
Posts: 15
Location: Salford, UK
Thanks for all the replies and especially Schnitzelbrain for the code. This works well in Windows 7 and has solved my problem for me.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group