VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Auto Start with Windows (fixed)

by Dound (7 Submissions)
Category: Registry
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

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

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

Rate Auto Start with Windows (fixed)

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

Download this snippet    Add to My Saved Code

Auto Start with Windows (fixed) Comments

No comments have been posted about Auto Start with Windows (fixed). Why not be the first to post a comment about Auto Start with Windows (fixed).

Post your comment

Subject:
Message:
0/1000 characters