使用启动文件夹设置文件 [英] Setup File with Start up Folder
问题描述
我已经创建了一个应用程序,我想创建一个设置文件,应用程序应该自动运行,就像我们将它移动到启动文件夹一样。但是我想在安装应用程序时保留它。
和第二件事,我想在我的应用程序关闭时实现,但该应用程序不应该退出,它将像任何反病毒软件,skypee等一样运行,我们可以从显示隐藏的图标
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
推荐答案
应用程序应该自动运行,就像我们将它移动到启动文件夹一样。
您需要使用Registry在启动时运行程序。您可以使用System.Win32
命名空间中的RegistryKey
类。以下代码显示了如何执行此操作:
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 theRegistryKey
class that's in theSystem.Win32
namespace. The following code shows how to do this:
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);
}
注意: RegistryKey
在 System.Win32
命名空间,因此不要忘记导入它。
参考:在启动时运行程序 [ ^ ]
'当我的申请结束时也会实施,但该申请不应该退出,
这里:
最小化窗口到系统托盘 [ ^ ]
C#系统托盘使用NotifyIcon最小化托盘 [<小时ef =http://alperguc.blogspot.in/2008/11/c-system-tray-minimize-to-tray-with.htmltarget =_ blanktitle =New Window> ^ ]
试试!
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!
这篇关于使用启动文件夹设置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!