|
using System;
using System.Windows.Forms;
using Microsoft.VisualBasic;
namespace GalleryCreator
{
/// <summary>
/// Summary description for RegistryWorks.
/// </summary>
internal class RegistryWorks
{
public const string strAppName = "LightBox Web Gallery Generator 1.1";
private const string strSection = "Startup";
public RegistryWorks()
{
}
/// <summary>
/// Saves or creates an application entry in the Windows registry
/// </summary>
/// <param name="strKey"></param>
/// <param name="strSetting"></param>
public static void SaveSetting(string strKey, string strSetting)
{
Interaction.SaveSetting(strAppName, strSection, strKey, strSetting);
}
/// <summary>
/// Returns a key setting value from an application's entry in the Windows registry
/// </summary>
/// <param name="strKey"></param>
/// <param name="strDefault"></param>
public static string GetSetting(string strKey, string strDefault)
{
return Interaction.GetSetting(strAppName, strSection, strKey, strDefault);
}
/// <summary>
/// Same as GetSetting, but returns int
/// </summary>
/// <param name="strKey"></param>
/// <param name="intDefault"></param>
/// <returns></returns>
public static int GetIntSetting(string strKey, int intDefault)
{
string strSetting = Interaction.GetSetting(strAppName, strSection, strKey, "");
if (strSetting.Length > 0)
{
try
{
return Int32.Parse(strSetting);
}
catch
{
return intDefault;
}
}
else
return intDefault;
}
/// <summary>
/// Same as GetSetting, but returns boolean
/// </summary>
/// <param name="strKey"></param>
/// <param name="blnDefault"></param>
/// <returns></returns>
public static bool GetBoolSetting(string strKey, bool blnDefault)
{
string strSetting = Interaction.GetSetting(strAppName, strSection, strKey, "");
if (strSetting.Length > 0)
{
try
{
return Boolean.Parse(strSetting);
}
catch
{
return blnDefault;
}
}
else
return blnDefault;
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.