Horje
startup c# class winform Code Example
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("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 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);
        }
     }
}




Csharp

Related
first or default c# automapper Code Example first or default c# automapper Code Example
IAuthorizationFilter OnAuthorization AuthorizationContext MyAuthorizeAttribute HttpUnauthorizedResult HttpContext Code Example IAuthorizationFilter OnAuthorization AuthorizationContext MyAuthorizeAttribute HttpUnauthorizedResult HttpContext Code Example
prometheus add prefix to metrics Code Example prometheus add prefix to metrics Code Example
get device name c# console Code Example get device name c# console Code Example
DataTable GetErrors Code Example DataTable GetErrors Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13