首页 ┆ 网站地图 ┆ 在线留言 ┆ 游戏资讯 ┆ 资源下载 ┆ 端午节祝福 ┆ 迅雷在线影视 ┆淘宝手机在线充值 ┆淘宝游戏点卡充值 
设为首页
加入收藏
联系我们
高级搜索
您当前的位置: 主页>NET专区>VB.NET>编写随Windows启动运行的程序
编写随Windows启动运行的程序
来源: 发布时间:2007-09-05 发布人: 浏览: 人次   字体: [ ]  

通过设置和读取注册表,可以实现我们的应用程序随Windows的启动即可执行的功能。下面就是实现的代码:

Form1.vb

Imports Microsoft.Win32.Registry Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows 窗体设计器生成的代码 " Public Sub New() MyBase.New() '该调用是 Windows 窗体设计器所必需的。 InitializeComponent() '在 InitializeComponent() 调用之后添加任何初始化 End Sub '窗体重写处置以清理组件列表。 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Windows 窗体设计器所必需的 Private components As System.ComponentModel.IContainer '注意:以下过程是 Windows 窗体设计器所必需的 '可以使用 Windows 窗体设计器修改此过程。 '不要使用代码编辑器修改它。 Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox Friend WithEvents btnSave As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.CheckBox1 = New System.Windows.Forms.CheckBox() Me.btnSave = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'CheckBox1 ' Me.CheckBox1.BackColor = System.Drawing.SystemColors.Control Me.CheckBox1.Checked = True Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Checked Me.CheckBox1.ForeColor = System.Drawing.SystemColors.ControlText Me.CheckBox1.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.RightToLeft = System.Windows.Forms.RightToLeft.Yes Me.CheckBox1.Size = New System.Drawing.Size(142, 15) Me.CheckBox1.TabIndex = 21 Me.CheckBox1.Text = "Windows开机即运行" Me.CheckBox1.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'btnSave ' Me.btnSave.BackColor = System.Drawing.SystemColors.Control Me.btnSave.Font = New System.Drawing.Font("宋体", 10.0!) Me.btnSave.ForeColor = System.Drawing.SystemColors.ControlText Me.btnSave.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.btnSave.Location = New System.Drawing.Point(0, 16) Me.btnSave.Name = "btnSave" Me.btnSave.Size = New System.Drawing.Size(144, 24) Me.btnSave.TabIndex = 32 Me.btnSave.Text = "保存设置" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(144, 40) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSave, Me.CheckBox1}) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Windows开机即运行" Me.ResumeLayout(False) End Sub #End Region Dim Reg As Microsoft.Win32.RegistryKey Private Sub InitVar() If btnSave.Visible = True Then End If Reg = CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) If Reg.GetValue("MengXianHui") <> "" Then CheckBox1.Checked = True Else CheckBox1.Checked = False End If End Sub Private Sub SaveSettings() If CheckBox1.Checked = True Then Reg = CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) Reg.SetValue("MengXianHui", Application.ExecutablePath) Else Reg = CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) Reg.SetValue("MengXianHui", "") End If InitVar() MessageBox.Show("您已经设置了,请重新启动计算机看效果。", "提示", _ MessageBoxButtons.OK, MessageBoxIcon.Information) If CheckBox1.Checked = True Then Me.Dispose(True) End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles btnSave.Click SaveSettings() End Sub End Class

↑上一篇:没有了
相 关 文 章   发布商链接
·捕捉DataGrid的双击事件
·向SQL Server数据库添加图片和文字
·如何用VB.Net创建一个三层的数据库应...
·如何有效地利用VB.Net编程实现PC与掌...
·vb.net访问Iframe示例代码
·vb.net实现从ListBox中拖放数据到Lis...
·从DataGridView拖放选中的行到ListBo...
·在Visual Basic 2005中操作文件和目...
·VB.NET调用SQL Server存储过程的方法...
·在.net中如何使用别人的ActiveX控件...
 §最新评论:(评论内容只代表网友观点,与本站立场无关!)
网名: 验证码:  【所有评论】【↑返回顶部
评 分: 12 345
评论内容:(不能超过500字,请自觉遵守互联网相关政策法规。[按 Ctrl+Enter 可直接提交]
注意:请勿在本站发布政治话题、色情及违反法律的内容。
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。
推 荐 文 章
·详解vb.net实现图片以二进制...
·vb.NET实现图片文件上加上文...
·vb.net实现上传图片并同时生...
·vb.net实现随机生成数字或字...
·如何在vb.net中使用ArrayList
·怎样通过VB.NET获得网卡地址...
·vb.NET中为组合框添加自动查...
·vb.NET下获取命令行参数的方...
·在.net中如何使用别人的Activ...
·VB.NET调用SQL Server存储过...
·在Visual Basic 2005中操作文
·从DataGridView拖放选中的行...
·vb.net实现从ListBox中拖放数
·vb.net访问Iframe示例代码
·如何有效地利用VB.Net编程实...
热 门 文 章
·在Visual Basic 2005中操作文...
·在.net中如何使用别人的Activ...
·VB.Net开发的运行任务计划小...
·vb.net实现随机生成数字或字...
·使用Mid函数实现字符串的替换...
·VB.Net判断目录或文件是否存...
·VB.NET调用SQL Server存储过...
·vb.net访问Iframe示例代码
·从DataGridView拖放选中的行...
·VB.NET实现的让TextBox控件只...
·vb.net实现按字节截取字符串...
·如何在vb.net中使用ArrayList...
·图解使用VB.net2008编写多种...
·vb.NET下获取命令行参数的方...
·vb.net获取当前url的方法代码...
网站首页 - 关于本站 - 加入收藏 - 网站地图 - 友情连接 - 在线留言 - 联系我们 - 返回顶部
Copyright © 2007 IT知道网.[冀ICP备07026896号]. All Rights Reserved .