Click here to Skip to main content
15,896,153 members
Articles / Programming Languages / C#

C# - Optical Marks Recognition (OMR) Engine 1.0

Rate me:
Please Sign up or sign in to vote.
4.77/5 (34 votes)
9 Mar 2015CPOL6 min read 298.3K   25.4K   107  
An API that reads OMR sheets from camera taken/ scanner scanned images.
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.

License

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


Written By
Engineer techCREATIONS
Pakistan Pakistan
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

Comments and Discussions