Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. registry handling

registry handling

Scheduled Pinned Locked Moved C#
windows-admintutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mostafa Siraj
    wrote on last edited by
    #1

    Hi all, i need to write some program to handle registry please give me some links or some guidence to do something . this type of programming is new for me so plz guide in detail. thanks in advance. Keep Praying

    J 1 Reply Last reply
    0
    • M Mostafa Siraj

      Hi all, i need to write some program to handle registry please give me some links or some guidence to do something . this type of programming is new for me so plz guide in detail. thanks in advance. Keep Praying

      J Offline
      J Offline
      JacquesDP
      wrote on last edited by
      #2

      This piece of code helped me alot, hope it'll work for you. /* *************************************** * ModifyRegistry.cs * --------------------------------------- * a very simple class * to read, write, delete and count * registry values with C# * --------------------------------------- * if you improve this code * please email me your improvement! * --------------------------------------- * by Francesco Natali * - fn.varie@libero.it - * ***************************************/ using System; // it's required for reading/writing into the registry: using Microsoft.Win32; // and for the MessageBox function: using System.Windows.Forms; namespace Utility.ModifyRegistry { /// /// An useful class to read/write/delete/count registry keys /// public class ModifyRegistry { private bool showError = false; /// /// A property to show or hide error messages /// (default = false) /// public bool ShowError { get { return showError; } set { showError = value; } } private string subKey = "SOFTWARE\\" + Application.ProductName.ToUpper(); /// /// A property to set the SubKey value /// (default = "SOFTWARE\\" + Application.ProductName.ToUpper()) /// public string SubKey { get { return subKey; } set { subKey = value; } } private RegistryKey baseRegistryKey = Registry.LocalMachine; /// /// A property to set the BaseRegistryKey value. /// (default = Registry.LocalMachine) /// public RegistryKey BaseRegistryKey { get { return baseRegistryKey; } set { baseRegistryKey = value; } } /* ************************************************************************** * **************************************************************************/ /// /// To read a registry key. /// input: KeyName (string) /// output: value (string) /// public string Read(string KeyName) { // Opening the registry key RegistryKey rk = baseRegistryKey ; // Open a subKey as read-only RegistryKey sk1 = rk.OpenSubKey(subKey); // If the RegistrySubKey doesn't exist -> (null) if ( sk1 == null ) { return null; } else { try { // If the RegistryKey exists I get its value // or null is returned. return (string)sk1.GetValue(KeyName.ToUpper()); } catch (Exception e)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups