这需要将要启动的应用程序路径写到注册表中具体的路径是:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
只需要在上面的路径下写一个键并为此键设置一个当前应用程序的路径即开机自载
具体的方法:
1、将下面这段代码就是将键Clock写到注册表中:
'设置注册表内的RUN属性
Dim strString As String
Dim keyhand As Long
Dim r As Long
strString = App.Path & "\" & App.EXEName & ".exe"
r = RegCreateKey(HKEY_LOCAL_MACHINE, "software\microsoft\windows\currentversion\run", keyhand)
r = RegSetValueEx(keyhand, "Clock", 0, REG_SZ, ByVal strString, Len(strString))
r = RegCloseKey(keyhand)
2、下面这段代码就是将注册表的Clock键删除
'删除注册表内的RUN属性
Dim keyhand As Long
r = RegOpenKey(HKEY_LOCAL_MACHINE, "software\microsoft\windows\currentversion\run", keyhand)
r = RegDeleteValue(keyhand, "Clock")
r = RegCloseKey(keyhand)
正文