Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

startup c# class winform

using System;
using System.Windows.Forms;
using Microsoft.Win32;

public class StartupManager : Form
{
    // The path to the key where Windows looks for startup applications
	static RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", true);
	/// <summary>
    /// Checking if the startup is already enabled or not
    /// </summary>
    /// <returns>Returns the state of the startup</returns>
	public static bool IsStartupInitialized()
	{
		return rkApp.GetValue(Application.ProductName) != null;
    }
    /// <summary>
    /// Changing the app startup state
    /// </summary>
    /// <param name="to">Set startup state to</param>
    public void SetStartupState(bool to)
    {
        if (to)
        {
            // Add the value in the registry so that the application runs at startup
            rkApp.SetValue(Application.ProductName, Application.ExecutablePath);
        }
        else
        {
            // Remove the value from the registry so that the application doesn't start
            rkApp.DeleteValue(Application.ProductName, false);
        }
     }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity get refresh rate 
Csharp :: Devexpress MVC Gridview BinaryImage Picture 
Csharp :: c# cosmos db add items into container 
Csharp :: Dictionary of array in C# 
Csharp :: c# string with double quotes inside 
Csharp :: difference between c# and .net 
Csharp :: telerik mvc grid round sum result 
Csharp :: c# decimal literal 
Csharp :: using selected item in listbox c# to fill texbox 
Csharp :: binaural generator 
Csharp :: c# get Full Exception message if InnerException is not NULL 
Csharp :: button commandfield commandargument pass textbox 
Csharp :: www.elking.net 
Csharp :: unity on statement how 
Csharp :: c# asqueryable select 
Csharp :: c sharp if statements 
Csharp :: create cursor in netezza 
Csharp :: umbraco cannot start. a connection string is configured but umbraco cannot connect to the database. 
Csharp :: vb.net ionic zip examples 
Csharp :: Difference between UnitOfWork and Repository Pattern 
Csharp :: how to check if every element in array is true c# 
Csharp :: hacker 
Csharp :: cs foreach int 
Csharp :: csvhelper driver c# nuget 
Csharp :: C# devexpress get foucused dataRow of child gridView 
Csharp :: csharp functions 
Csharp :: short in c# 
Csharp :: Open Windows Explorer to a certain directory from within a WPF app 
Csharp :: c# random change seed 
Csharp :: Dynamically checking IList<T C# 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =