Results 1 to 2 of 2

Thread: Load App. during startup ???

  1. #1

    Thread Starter
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    How do I make my app. such that when the user runs it on his pc for the first time the registry or whatever is edited so that whenever windows is started again my applications gets started and rests in the system tray.(IU don't want to use activex to do so becoz I wnat to learn it using API's)

    Please help.
    Thanks in advance.

    Kinjal

  2. #2
    Guest
    Try this:

    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 Main()
        Call SetStartupProgram("Project1", "C:\Project1.exe")
    End Sub
    
    Public Function SetStartupProgram(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