C# realizes automatic startup setting code sharing
Updated: July 6, 2015 12:09:29 Submission: junjie
This article mainly introduces the sharing of the setting code for automatic startup of C#. This article directly gives the implementation code. Friends who need it can refer to it.
/// <summary> /// Set the program to start /// or cancel the startup /// </summary> /// <param name="started">Set the startup on or cancel the startup on</param> /// <param name="exeName">The name of the program in the registry</param> /// <param name="path">Program path for startup</param> /// <returns>Whether it is successful when it is turned on or disabled</returns> public static bool runWhenStart(bool started, string exeName, string path) { RegistryKey key = ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//Open the registry subkey if (key == null)//If this item does not exist, create the child item { key = ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } if (started == true) { try { (exeName, path);//Set to boot (); } catch { return false; } } else { try { (exeName);//Cancel startup (); } catch { return false; } } return true; }
Related Articles
The C# winform program realizes self-start on the computer and identifies whether it is started on the computer or double-click to start.
This article mainly introduces the implementation code of the C# winform program to realize the startup and identify whether it is startup or double-click to start. The code is simple and easy to understand, very good, and has certain reference value. Friends who need it can refer to it.2018-10-10Example of OCX control written by C# Call vc
This article mainly introduces the example of OCX control written by C# calling vc. Friends who need it can refer to it2014-04-04C# 3.0 How to write Windows event logs using EventLog class
This article mainly introduces the method of using the EventLog class to write Windows event logs in C# 3.0. It analyzes the skills of writing Windows event logs in C# in the form of a simple example. It has certain reference value. Friends who need it can refer to it.2015-08-08Methods of image binarization (color to black and white) in C# digital image processing
This article mainly introduces the method of image binarization (color to black and white) in C# digital image processing, which can realize the effect of image transformation from color to black and white. It is very practical. Friends who need it can refer to it2015-04-04C# Page is used for inheriting function examples of each page
This article mainly introduces C# Page's function examples for inheriting functions of each page, including common page views, data caching, database operations and other techniques. Friends who need it can refer to it2014-10-10C# implements the method of setting the application to boot
This article mainly introduces the method of setting the application to boot up in C#. It involves C#'s writing skills for registry, and has certain reference value. Friends who need it can refer to it.2015-09-09C# implements the sharing of ini file reading and writing classes
C# implements the sharing of ini file reading and writing, please refer to it and use it2013-12-12Method for calculating image mean variance in C# image processing
This article mainly introduces the method of calculating the mean variance of image in C# image processing, involving the calculation techniques of C# image mean variance. Friends who need it can refer to it2015-04-04== operator in C#
This article mainly introduces the == operator in C#, which is very good and has reference value. Friends who need it can refer to it.2017-06-06Analysis of Socket Operation Class Instance in C#
This article mainly introduces the usage of Socket operation class in C#. Friends who need it can refer to it.2014-08-08