|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace OMR
{
public class RegistryEditor
{
public static void WriteRegStr(string AppName, string ValueName, object value)
{
RegistryKey MyKey = Registry.CurrentUser.CreateSubKey("Software\\" + AppName, RegistryKeyPermissionCheck.ReadWriteSubTree);
try
{
MyKey.SetValue(ValueName, Convert.ToInt32(value), RegistryValueKind.DWord);
}
catch
{
MyKey.SetValue(ValueName, value.ToString(), RegistryValueKind.String);
}
}
public static void DeleteReg(string AppName, string ValueName)
{
RegistryKey MyKey = Registry.CurrentUser.CreateSubKey("Software\\" + AppName, RegistryKeyPermissionCheck.ReadWriteSubTree);
try
{
MyKey.DeleteValue(ValueName);
}
catch
{
}
}
public static object ReadReg(string AppName, string ValueName)
{
RegistryKey MyKey;
try
{
MyKey = Registry.CurrentUser.OpenSubKey("Software\\" + AppName, RegistryKeyPermissionCheck.ReadWriteSubTree);
if (MyKey == null)
throw new NullReferenceException();
}
catch
{
MyKey = Registry.CurrentUser.CreateSubKey("Software\\" + AppName, RegistryKeyPermissionCheck.ReadWriteSubTree);
}
try
{
object obj = MyKey.GetValue(ValueName) ;
if (obj == null)
throw new Exception();
return obj;
}
catch
{
WriteRegStr(AppName, ValueName, false);
object obj = MyKey.GetValue(ValueName);
return obj;
}
}
}
}
|
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.
Developer, Programmer, Beta Tester; technically, i'm none of these. I'm a mechanical engineer, programming is my passion, my hobby and my amateur non profit profession. I program when ii need and innovate whenever, wherever i want.
Learned:
C#
Mixed:
C#+Applied Mathematicss-Robotics+C++
Developed:
C# OMR Reader
Monopoly (Urdu language)
HybridAutomation Framework
SMS Bomber (Windows Mobile 6 Professional)
Hard disk watch tower
Farmville Super Clicker
Games Profile selector
Windows mobile salat reminder
Windows mobile SMS Pole Host
and alot of other small apps