如何让我的程序在启动时运行? [英] How to make my program run at startup?

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

问题描述

我正在编写一个类似于 Google 桌面的桌面应用程序,但使用我自己的带有 vb.net 2008 的小工具,如何让我的应用程序在用户将其安装到计算机上时在启动时运行?

I'm programming a desktop application similar to Google desktop but with my own gadget with vb.net 2008 how can i make my application when the user install it on their computer to run at the time of start up?

假设我的应用程序名称是 windowsAplication1 并且我使用的是 windows XP 并且程序将安装在 C 盘上?

Let assume that my application name is windowsAplication1 and I'm using windows XP and the program will be installed on C drive?

推荐答案

您可以使用以下代码将其添加到注册表

You can add it to registry with the following code

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)

您可以使用

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(Application.ProductName)

上面的代码将它添加到所有用户.您可以通过以下键将其添加到当前用户

The above code will add it to all users. You can add it to current user in the following key

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

或者您可以在启动"文件夹中添加指向您的应用程序的链接.

Or you can add a link to your application in the "Startup" folder.

我建议你不要自动执行它可能会刺激用户.我讨厌应用程序自动将它们添加到 Windows 启动.为用户提供在 Windows 启动时运行程序的选项.

I suggest you dont do it automatically it may irritate the user. I hate when apps add them automatically to Windows Startup. Give an option for the user to run the program on windows startup.

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

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