Results 1 to 7 of 7

Thread: startup

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    medina, OH
    Posts
    125
    How do I get my app to load at startup?

  2. #2
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    Put a shortcut to your exe in the startup folder. It can be found at:

    c:\windows\start menu\start up

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    medina, OH
    Posts
    125

    startup

    sorry i wasnt specific enough, I want the program
    to copy itself to the startup menu.

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    The easiest way is to create a string value in the registry, in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run.
    The key's name doesn't matter (use App.Title), and the value should be:
    Code:
    App.Path & IIf(Right(App.Path, 1) = "\", vbNullString, "\") & App.EXEName & IIf(LCase(Right(App.EXEName, 4)) = ".exe", vbNullString, ".exe")
    This is the easiest because the Startup folder may differ, but the registry location is always the same.
    To set the value there, use the Registry API functions...

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    medina, OH
    Posts
    125

    thanks

    thanks for the help

  7. #7
    Guest
    Here is an example of Yonatan's idea:

    Code:
    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
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) 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 Const HKEY_LOCAL_MACHINE = &H80000002
    Private Const ERROR_SUCCESS = 0&
    Private Const REG_SZ = 1
    Private Const KEY_SET_VALUE = &H2
    
    Private Sub Command1_Click()
        Call SetProgramStartup("MyProg", "C:\MyProg.exe")
    End Sub
    
    Public Function SetProgramStartup(pProgramName As String, pProgramPath As String) As Boolean
        Dim lKeyHandle As Long
        Dim lRet As Long
        Dim strBuffer As String
        Dim strKey As String
        
        strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
        lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_SET_VALUE, lKeyHandle)
        If lRet = ERROR_SUCCESS Then
          lRet = RegSetValueEx(lKeyHandle, pProgramName, 0, REG_SZ, ByVal pProgramPath, Len(pProgramPath))
          RegCloseKey lKeyHandle
        End If
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width