Click here to Skip to main content
Licence CPOL
First Posted 6 Apr 2005
Views 30,167
Bookmarked 16 times

Registry Wrapper to save your Application settings

By | 6 Apr 2005 | Article
This article describes a Registry wrapper to save your application settings like recent files information.

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThank you Pinmemberkorrawit22:17 14 Nov '07  
GeneralTypical "China-code" (nothing personal) Pinmemberlastochkin3:59 2 Oct '07  
GeneralThanks for the article, I like it. Pinmemberspinoza3:12 12 Oct '06  
GeneralXML configuration files PinmemberDaniel Fisher (lennybacon)1:33 13 Apr '05  
AnswerRe: XML configuration files PinmemberRGabo15:38 1 Sep '05  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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