Solved

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

Posted on 2006-11-04
5
147 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now