文档库 最新最全的文档下载
当前位置:文档库 › VB的开机自动运行程序的代码

VB的开机自动运行程序的代码

VB的开机自动运行程序的代码
VB的开机自动运行程序的代码

VB的开机自动运行程序的代码

先引用系统文件夹有的WSHom.Ocx

'*************************************************************************

'**函数名:SetAutoRun

'**输入:ByVal Autorun(Boolean) -

'**输出:无

'**功能描述:随WINDOWS自动启动/取消启动模块

'**全局变量:

'**调用方法:Call SetAutoRun(True/False)

'**作者:mythhack

'**日期:2011年12月29日11:10:42

'**修改人:邱建忠

'**日期:

'**版本:V1.0.0

'*************************************************************************

Public Sub SetAutoRun(ByVal Autorun As Boolean)

'WshShell 对象

'ProgId Wscript.Shell

'文件名WSHom.Ocx

Dim WshShell

Set WshShell = CreateObject("Wscript.Shell")

If Autorun Then

WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & App.EXEName, App.Path & "\" & App.EXEName & ".exe"

Else

WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & App.EXEName

End If

Set WshShell = Nothing

End Sub

相关文档