Click here to Skip to main content
15,894,106 members
Articles / Programming Languages / C#

Howto: (Almost) Everything in WMI via C# - Part 1: Registry

Rate me:
Please Sign up or sign in to vote.
3.71/5 (14 votes)
19 Oct 2007CPOL2 min read 106.1K   2.9K   75  
A class library that wraps WMI Win32 Registry.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace baileySoft.Wmi.Registry
{
    abstract class RegistryObject
    {
        #region "fields"
        private bool isConnected;
        private string currentSize; //Win32_Registry properties placeholders
        private string caption;
        private string description;
        private string installDate;
        private string maximumSize;
        private string name;
        private string proposedSize;
        private string status;
        #endregion
   
        #region "properties"
        public bool IsConnected
        {
            get { return isConnected; }
            set { isConnected = value; }
        }
        public string CurrentSize
        {
            get { return currentSize; }
            set { currentSize = value; }
        }
        public string Caption
        {
            get { return caption; }
            set { caption = value; }
        }
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        public string InstallDate
        {
            get { return installDate; }
            set { installDate = value; }
        }
        public string MaximumSize
        {
            get { return maximumSize; }
            set { maximumSize = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public string ProposedSize
        {
            get { return proposedSize; }
            set { proposedSize = value; }
        }
        public string Status
        {
            get { return status; }
            set { status = value; }
        }
        #endregion

        public abstract void CreateKey(baseKey RootKey, string key);
        public abstract void DeleteKey(baseKey RootKey, string key);
        public abstract ArrayList EnumerateKeys(baseKey RootKey, string key);
        public abstract ArrayList EnumerateValues(baseKey RootKey, string key);
        public abstract string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType);
        public abstract void SetValue(baseKey RootKey, string key, string valueName, string value, valueType ValueType);
        public abstract void CreateValue(baseKey RootKey, string key, string valueName, string value);
        public abstract void DeleteValue(baseKey RootKey, string key, string valueName);
        public abstract void GetRegistryProperties();
        public abstract bool Connect();
       
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer
United States United States
I'm a professional .NET software developer and proud military veteran. I've been in the software business for 20+ years now and if there's one lesson I have learned over the years, its that in this industry you have to be prepared to be humbled from time to time and never stop learning!

Comments and Discussions