title: Adding application to registry for run at startup using c#
body: <p>I have added this code for run at start up</p>
  
  <pre><code>public static void AddApplicationToStartup()
  {
      using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
      {
          key.SetValue("My Program", "\"" + Application.ExecutablePath + "\"");
      }
  }
  </code></pre>
  
  <p>and i have called this function at the very first line of Main function.
  the problem is this will run every time. but how can we check that this application is already added to registery??</p>