且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在用户启动必须在后台运行的系统时启动Windows应用程序

更新时间:2023-12-04 10:05:22

创建Windows服务而不是应用程序,它们在后台运行并可以自动启动



另请注意; Windows服务的优先启动时间高于所有其他基于标准表单的应用程序,它们也可以在用户登录Windows之前运行。



您可以按照此处列出的MSDN文档开始使用

如何:以编程方式编写服务
Create a Windows Service rather than an application, they run in the background and can start automatically

Also note; windows services have a priority startup time above all other standard form based applications, and they can also be run before a user logs into windows itself.

You can get started by following the MSDN docs listed here
How to: Write Services Programmatically


我的理解:您希望在以下位置运行您的应用程序Windows启动。



你能做什么:



1)点击开始菜单,选择所有程序,找到Startup文件夹,右键单击,然后单击Open。​​



2)创建一个链接到程序的快捷方式并将其移动到Startup文件夹。



3)如果您不想展示您的应用程序,请打开您的解决方案,转到您的设计师,选择Form1或其他任何名称,然后转到属性面板,更改显示图标选项为False,最后,将WindowState设置为Minimized。



就是这样。当您再次运行Windows时,您的应用程序应该在用户登录后自动启动。



希望这会有所帮助!干杯! - CCB
What I understand: You want to run your application at windows startup.

What you can do:

1) Click on Start Menu, select All Programs, and locate Startup folder, right-click, and click on Open.

2) Make a shortcut linked to your program and move it to Startup folder.

3) If you don't want to show your application, open your solution, go to your designer, select the Form1 or whatever it's called, and go to Properties Panel, change "Show Icon" option to "False", finally, set WindowState to "Minimized".

That's it. When you run Windows again, your application should automatically start after the user log.

Hope this helps! Cheers! - CCB


我想你想要隐藏你想要运行的应用程序吗?

这是我的解决方案:

1st。你需要在Windows启动后立即启动它。

这是在Windows启动后立即添加软件/程序的代码:

I guess you want to hide the application you want to run right?
Well here's my solution:
1st. You need to start it right after the windows start up.
This is the code in adding your software/program run right after the windows start-up:
//adding to microsoft startup program
//using Microsoft.Win32;
using (RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
    reg.SetValue(ProjectTitle, Defaultpath + ProjectName);
}

//removing to startup program
/*using (RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
    reg.DeleteValue(ProjectTitle,false);
}*/





第二名。而且你需要在代码中隐藏表单,你的程序已经运行了后台,并且由你自己决定要运行你的程序背景。



和这里隐藏表格的代码:

this.Hide();





希望它能帮助你先生。



2nd. And you need to hide the forms in code and your program is running background already, and its up to you what you want to do it just happen that you want to run your program background.

and here the code to hide your Form:
this.Hide();


hope it'll help you sir.