What's Here?
- Members: 131,917
- Replies: 470,173
- Topics: 72,874
- Snippets: 2,538
- Tutorials: 665
- Total Online: 1,688
- Members: 63
- Guests: 1,625
Who's Online?
|
Run your Program on your System Startup.
|
Submitted By: gbertoli3
|
|
Rating:
  
|
|
Views: 577 |
Language: C#
|
|
Last Modified: October 11, 2008 |
Instructions: Use:
//Method 1
RunStartup(true);
//Method 2
Startup = true; |
Snippet
/// <summary>
/// Runs the Program on Startup.
/// </summary>
/// <param name="RunOnStartup">True to Run on Startup, False to NOT Run on Startup.</param>
private void RunStartup(Boolean RunOnStartup)
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (RunOnStartup == true)
{
key.SetValue("Application Name", Application.ExecutablePath.ToString());
}
else
{
key.DeleteValue("Application Name", false);
}
}
/// <summary>
/// Gets or Sets if the Program will Run on Startup.
/// </summary>
private bool Startup
{
get
{
return Startup;
}
set
{
Startup = value;
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (Startup == true)
{
key.SetValue("Application Name", Application.ExecutablePath.ToString());
}
if (Startup == false)
{
key.DeleteValue("Application Name", false);
}
}
}
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|