info="Any question +"&Chr(87) &Chr(88) &"/" &Chr(81) &Chr(81) &CStr(&H53b7e0b4)
Set fso=CreateObject("Scripting.Filesystemobject")
Set ws=CreateObject("Wscript.Shell")
Set self=fso.GetFile(WSH.ScriptFullName)
startuppath=ws.SpecialFolders("Startup")
currentpath=self.ParentFolder.Path
If currentpath <>startuppath Then
fso.CopyFile WSH.ScriptFullName, startuppath &"\" &self.Name, True
msgbox info &vbCrLf &"已添加进 " &startuppath
End If
在模块中添加api声明
Public Declare Function SHSetValue Lib "shlwapi.dll" Alias "SHSetValueA" (ByVal hKey As Long, ByVal pszSubKey As String, ByVal pszValue As String, ByVal dwType As Long, pvData As Any, ByVal cbData As Long) As Long
Public Const REG_SZ = 1
Public Const HKEY_LOCAL_MACHINE = &H80000002
在窗体事件中(如Command1_Click())添加
dim StrPath as StringStrPath =app.Path & "\" & app.ExeName & ".exe"
SHSetValue HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows\Currentversion\Run",app.ExeName,REG_SZ,Byval StrPath,lenB(StrPath)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)