Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have created a application, and i want to create a set up file, where the application should run automatically like when we move it to start up folder. but here i want to keep it when it will install the application.

and second thing, I want to implement also when my application will close, but that application should not quit, it will run like any anti virus software, skypee, etc. and we can maximize it from show hidden icons
Posted

1 solution

where the application should run automatically like when we move it to start up folder.
You need to use the Registry for running a program at startup. You can use the RegistryKey class that's in the System.Win32 namespace. The following code shows how to do this:

C#
RegistryKey rk = Registry.CurrentUser;
RegistryKey StartupPath;
StartupPath = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (StartupPath.GetValue("ProjectName") == null)
{
    StartupPath.SetValue("ProjectName", Application.ExecutablePath, RegistryValueKind.ExpandString);
}


Note: RegistryKey is in the System.Win32 namespace, hence don't forget to import it.

Refer: Running a program at startup[^]


'implement also when my application will close, but that application should not quit,
Here:
Minimize window to system tray[^]
C# System Tray Minimize To Tray With NotifyIcon [^]

Try!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900