在需要时运行程序 [英] run programs when we need

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

问题描述

hello
how to run a program when computer restart?

推荐答案

您可以执行许多选择.

A)您可以在开始文件夹中放置程序的快捷方式.操作系统加载后,这将自动启动程序.

B)您可以使用Windows服务来启动程序.



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

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[^]



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

请参阅:在启动时运行程序 [ ^ ]


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

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