README.md

December 5, 2022 ยท View on GitHub

Auto Start with Windows (fixed)

Description

Make your program start when windows starts. Short and easy.

More Info

Submitted On
ByDound
LevelIntermediate
User Rating5.0 (10 globes from 2 users)
CompatibilityVB 5.0, VB 6.0
CategoryRegistry
WorldVisual Basic
Archive File

API Declarations

Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long

Source Code

Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Const REGKEY = "Software\Microsoft\Windows\CurrentVersion\Run"
Const KEY_WRITE = &H20006
Dim path As Long
'Tell windows to make Autopaper autostart with windows
If RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY, 0, KEY_WRITE, path) Then Exit Sub
RegSetValueEx path, App.Title, 0, REG_SZ, ByVal App.path & "\startprog.exe", Len(App.path & "\programsfilename.exe")
    'DELETE AUTOSTART:
    'If RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY, 0, KEY_WRITE, Path) Then Exit Sub
    'RegDeleteValue Path, App.Title