在c#中以starup启动程序 [英] Start program on starup in c#

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

问题描述

我想在启动Windows时启动我的应用程序。

为此我已经使用了

HKEY_LOCAL_MACHINE\SOFTWARE \ Microsoft \ Windows \ CurrentVersion \\ \\Run注册表值

它工作正常。



但现在我想从c#代码中设置注册表值

但是我不能在编程中编辑或添加新的值。

你能说怎么做???

I want to start my application on start up of windows.
For that i have used
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run registry value
and it worked correct.

But now i want to set the registry value from c# code
but i cann''t edit or add new value in registry programtically.
can u say how to do this???

推荐答案

如果您正在尝试写入HKLM,请确保您具有管理员权限。如果不是,注册表写入尝试将失败。我怀疑您是从一个(管理员)用户名手动添加值并尝试从另一个(非管理员)用户名运行您的程序。
If you are trying to write to HKLM, make sure that you have admin privileges. If not the registry write attempt will fail. I suspect that you are manually adding the value from one (admin) username and trying to run your program from another (non-admin) username.


您可以添加程序的快捷方式开始菜单中的启动文件夹,应该在每次启动操作系统时启动程序。
You can add a shortcut of the program to the startup folder in the start menu, that should start your program everytime you start the OS.


您需要使用resgitry类来访问(读取或写入)注册表值。



http://msdn.microsoft.com/en -us / library / 5f1xf5kf.aspx [ ^ ]



看看这篇文章来了解一下:



http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-editing- -wind-registry [ ^ ]
You need to use the resgitry class to access (read or write) registry values.

http://msdn.microsoft.com/en-us/library/5f1xf5kf.aspx[^]

Look at this article to get a heads up:

http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-editing-the-windows-registry[^]


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

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