Results 1 to 7 of 7

Thread: Getting my program to start with Windows

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    43

    Getting my program to start with Windows

    Well ive always wanted my program to startup with windows... I have been told about 2000 times (literaly) just to add it to my startup folder.. this isnt good enough for me and i need my program to control wether it starts up with windows or not... anything will work for me... i dout its this easy but if its possible to just get a timer and fill it up with script to do this thats great plz tell me the script... as i said i dout its done that way... but all i really need is for my program to come up on startup without me adding its shortcut to the startup folder or it least not having me add it manualy... its ok if the program does that by itself the first time u open it, but i would DEFINATLY prefer it to have nothing to do with the windows startup folder and more the program!
    Last edited by TarheelsLAX10; Feb 3rd, 2003 at 08:05 PM.
    Life sucks and then you die.
    So before you die absorb some VB!

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    43
    Oh My Gosh someone hasta know...
    Life sucks and then you die.
    So before you die absorb some VB!

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    43
    Awww plz someone answer... at least tell me if its possible or not...
    Life sucks and then you die.
    So before you die absorb some VB!

  4. #4
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    have your program add its path to the autoexec.bat

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    43
    have ne script for that?
    Life sucks and then you die.
    So before you die absorb some VB!

  6. #6
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Or you could just search the forums for the 49 threads that've been started on this same exact subject.
    Please rate my post.

  7. #7
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308
    (Originally posted by Peet)

    Make .exe of your application, run it once and restart your computer.

    VB Code:
    1. '  General Section
    2. Option Explicit
    3.  
    4. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
    5. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    6. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
    7. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
    8. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    9. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    10. 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
    11. Private Const REG_SZ = 1                         ' Unicode nul terminated string
    12. Private Const REG_DWORD = 4                      ' 32-bit number
    13. Private Const ERROR_SUCCESS = 0&
    14.  
    15.  
    16. Public Enum pvpHK
    17.     HKEY_CLASSES_ROOT = &H80000000
    18.     HKEY_CURRENT_USER = &H80000001
    19.     HKEY_LOCAL_MACHINE = &H80000002
    20.     HKEY_USERS = &H80000003
    21.     HKEY_PERFORMANCE_DATA = &H80000004
    22. End Enum
    23.  
    24. Private Const pvpRunHKey = "Software\Microsoft\Windows\CurrentVersion\Run"
    25.  
    26.  
    27. Private Sub savestring(ByVal Hkey As Long, strPath As String, strValue As String, strData As String)
    28.     Dim keyhand As Long
    29.     Dim r As Long
    30.     r = RegCreateKey(Hkey, strPath, keyhand)
    31.     r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    32.     If r = 87 Then
    33.         'Tom streng! -> må slettes
    34.         DeleteValue Hkey, strPath, strValue
    35.     End If
    36.     r = RegCloseKey(keyhand)
    37. End Sub
    38.  
    39. Private Function DeleteValue(ByVal Hkey As Long, ByVal strPath As String, ByVal strValue As String)
    40.     Dim keyhand As Long
    41.     Dim r As Long
    42.     r = RegOpenKey(Hkey, strPath, keyhand)
    43.     r = RegDeleteValue(keyhand, strValue)
    44.     r = RegCloseKey(keyhand)
    45. End Function
    46.  
    47. Public Function RunAtStartup(sAppTitle As String, strsAppName As String)
    48.          savestring pvpHK.HKEY_CURRENT_USER, pvpRunHKey, sAppTitle, strsAppName
    49. End Function
    50.  
    51. '  Any event such as form load or click of a button
    52. Private Sub Form_Load()
    53.     Text1.Text = "button is clicked"
    54.    
    55.     RunAtStartup App.Title, App.Path & "\" & App.EXEName & ".EXE"
    56. End Sub

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