Solved

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

Posted on 2006-11-04
5
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Include MS Database in Winforms Project using Intellilock 5 34
Convert VB web project to C# 3 65
Adjust the codes 3 63
C# Change the instruction to user. 11 39
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

737 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