Search Tools Links Login

Auto Start with Windows (fixed)


Visual Basic 6, or VB Classic

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

Original Author: Dound

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

Code

Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Const REGKEY = "SoftwareMicrosoftWindowsCurrentVersionRun"
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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 96 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.