Click here to Skip to main content
Click here to Skip to main content

Registry Wrapper to save your Application settings

By , 6 Apr 2005
 

Introduction

This article describes a Registry wrapper to save your application settings like recent files information.

Using the code

1. Save your application setting

This will save your setting at HKEY_CURRENT_USER\Software:

MyReg reg=new MyReg("AppName");  //Change AppName with your application name
reg["setting1"]=1;
reg[@"setting1\setting1"]="2";
reg[@"setting1\setting1\setting1"]="3";

2. Retrieve your application setting

MessageBox.Show(reg["setting1"].ToString());
MessageBox.Show(reg[@"setting1\setting1"].ToString());
MessageBox.Show(reg[@"setting1\setting1\setting1"].ToString());

3. Delete your setting

reg.Delete();

4. Save recent files

Add your recent files in an ArrayList.

ArrayList list=new ArrayList();
list.Add(@"c:\file1.txt");
list.Add(@"c:\file2.txt");
reg.RecentFiles=list;
list.Clear();
list=reg.RecentFiles;
MessageBox.Show(list[1].ToString());

5. Save file extension opener

To open file *.abc with your application, use the code below:

reg.SaveOpenWith("abc", "myApplication", 
               @"c:\Project\Vc7\Km\Debug\Km.exe");

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Yulianto.
CEO Odihost
Indonesia Indonesia
Member
Learned programming since elementry school with QBASIC. Until now have learned a bit about VB, java, html, php, asp, delphi. He is taking his master degree in finance. Currently working for a great company(desain web), and stock trading. Own various website about option strategy, lose weight, and Invest Money.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThank youmemberkorrawit14 Nov '07 - 22:17 
It is very good source.
GeneralTypical "China-code" (nothing personal)memberlastochkin2 Oct '07 - 3:59 
Pretty sample: continuous "copy'n'paste"s flavoured with "try/catch{}"s for error diagnostics preventing. Shame!

 
//\ Las!

GeneralThanks for the article, I like it.memberspinoza12 Oct '06 - 3:12 
See Subject.
 
Thanx
 
//Spinoza

GeneralXML configuration filesmemberDaniel Fisher (lennybacon)13 Apr '05 - 1:33 
You know what XML configuration files are for?
 
# THIS CODE AND INFORMATION ARE PROVIDED
# "AS IS" WITHOUT WARRANTY OF ANY
# KIND, EITHER EXPRESSED OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE
# IMPLIED WARRANTIES OF MERCHANTABILITY
# AND/OR FITNESS FOR A PARTICULAR PURPOSE.
# http://www.lennybacon.com/
AnswerRe: XML configuration filesmemberRGabo1 Sep '05 - 15:38 
Not for this.
 
And your signature is ridicilous btw.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 7 Apr 2005
Article Copyright 2005 by Yulianto.
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid