Solved

How can I store and retrieve a string value in somewhere in register?

Posted on 2006-11-04
5
150 Views
Last Modified: 2010-04-16
Hi, I would like to store a string (a network domain) so my application during startup can use that to bind to and build a TreeView control nodes based on that.  How can I store or retrieve that information and where in the registery can I store this?  Thanks.
0
Comment
Question by:lapucca
5 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17875269
Hi,

there is an exellent example below:

http:Q_21519280.html "Read and Write to registry in C#:"

which tells you how to write and retreive data from teh registry in c#.  If this is insufficient can you please let me know?
0
 

Author Comment

by:lapucca
ID: 17875280
Thank you.  I think that link could be enough on how to write and retrieve data from registry.
Where is a good place in the registery for me to store this string information for my applicaton?  Thanks.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17875292
Hi,

I would put in HKEY_LOCAL_MACHINE\SOFTWARE\YOURAPPNAME\

unless there is a particular reason why you do not want it available to people to see.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17875621
Important consideration for using the registry:

Store user specific information in HKEY_CURRENT_USER\SOFTWARE\YOURAPPNAME - only store system wide settings in HKEY_LOCAL_MACHINE. This is for a couple of reasons:
1. User preferences are USER preferences and not machine preferences.
2. In a 'shared' environment such as Citrix, multiple users actually run the same software on the same server simultaneously. Sharing changed settings in a common store creates havoc.
3. The user may not be an administrator, and therefore may not have permission to write to the HKLM registry hive (usually software is installed as administrator in these scenarios).

Cheers
Night
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17876090
if u are not very specific about storing it in the registry u could store it in th App config file

u could add a file of the type application confiruation file

and add

<add key="DOMAIN" value="IRIS\DBSERVER" />


u could retrieve it by
System.Configuration.ConfigurationSettings.AppSettings["DOMAIN"]

in code
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question