应用程序将在启动时启动 [英] Application to be started at startup

查看:92
本文介绍了应用程序将在启动时启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个Windows应用程序.我需要此程序在启动时运行.我真正需要的是Windows启动时(系统启动)
用户应该会弹出一个要启动该程序的窗口,如果单击是",则该窗口应自动启动.

有人可以为此提供我的代码吗?

I have a windows application developed.I need this program to run at startup. What exactly I need is when the windows starts(system starts)
the user should get a popup do you want to start this program, if clicked on yes it should be startted automatically.

Can anyone please provide me code for this?

推荐答案

您会找到 ^ ]问题已经在CP上发布,并且非常受欢迎.

我相信肯定可以解决这个问题.
You will find THIS[^] question is already posted in CP before and got a huge of popularity.

This I am sure definitely will get you out of trouble.


您需要在启动时使用注册表来运行程序.您可以使用System.Win32名称空间中的RegistryKey 类.以下代码显示了如何执行此操作:

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:

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);
}



注意:RegistryKeySystem.Win32名称空间中,因此请不要忘记导入它.



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


我做了一个简单的Google搜索,这就是我发现的内容:
设置程序以在启动C#时运行 [ 270,000个结果 [
I did a simple Google search and this is what I found:
set a program to run at startup c#[^]

This is the first link from 270,000 results[^] that I got.

So you see the power of search engines?! Use them and you will save everyone a lot of time. :thumbsup:


这篇关于应用程序将在启动时启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆