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

Registry Wrapper to save your Application settings

, 6 Apr 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Yulianto.
CEO Odihost
Indonesia Indonesia
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.

Comments and Discussions

 
GeneralThank you Pinmemberkorrawit14-Nov-07 22:17 
GeneralTypical "China-code" (nothing personal) Pinmemberlastochkin2-Oct-07 3:59 
GeneralThanks for the article, I like it. Pinmemberspinoza12-Oct-06 3:12 
GeneralXML configuration files PinmemberDaniel Fisher (lennybacon)13-Apr-05 1:33 
AnswerRe: XML configuration files PinmemberRGabo1-Sep-05 15:38 

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.

| Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 7 Apr 2005
Article Copyright 2005 by Yulianto.
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid