Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2004
    Location
    Earth, located in Milky Way galaxy
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Load on startup in VB

    I have been looking for a code which can load application on startup using Visual Basic and got plenty but failed to get a simple one as the codes which i got was bundled with other programs so couldn't understand the code and re-use it...

    Can anyone send me the code to load application in Visual Basic on startup. thank you
    You must dream to be a succesful person, go to sleep... www.niumai.tk is my site

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    VB...what? .net? 6? 7?

    using .net:
    Code:
    Imports Microsoft.Win32
    
    Dim boolRegWrite As Boolean
    Dim strPathToApp as String
    Dim strAppName as String
    
    strPathToApp = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"
    strAppName   = "My Application"
    boolRegWrite = WriteToRegistry(RegistryHive.LocalMachine, strPathToApp, strAppName, "Y")
    
    Pubilc Function WriteToRegistry(ByVal ParentKeyHive As RegistryHive, ByVal SubKeyName As String, ByVal ValueName As String, _
                                    ByVal Value As Object) As Boolean
    
        Dim objSubKey As RegistryKey
        Dim sException As String
        Dim objParentKey As RegistryKey
        Dim boolReturn As Boolean
        
        boolReturn = True
    
        Try
            Select Case ParentKeyHive
                Case RegistryHive.ClassesRoot
                    objParentKey = Registry.ClassesRoot
                Case RegistryHive.CurrentConfig
                    objParentKey = Registry.CurrentConfig
                Case RegistryHive.CurrentUser
                    objParentKey = Registry.CurrentUser
                Case RegistryHive.DynData
                    objParentKey = Registry.DynData
                Case RegistryHive.LocalMachine
                    objParentKey = Registry.LocalMachine
                Case RegistryHive.PerformanceData
                    objParentKey = Registry.PerformanceData
                Case RegistryHive.Users
                    objParentKey = Registry.Users
            End Select
            
            
            'Open Registry Key
            objSubKey = objParentKey.OpenSubKey(SubKeyName, True)
            
            'create if doesn't exist
            If objSubKey Is Nothing Then
                objSubKey = objParentKey.CreateSubKey(SubKeyName)
            End If
            
            objSubKey.SetValue(ValueName, Value)
            
        Catch ex As Exception
            boolReturn = False
        
        End Try
    
        Return boolReturn
    
    End Function
    Note that I borrowed some code found here, cleaned it up, and added the appropriate registry key.

    -Celt

  • #3
    New Coder
    Join Date
    Apr 2004
    Location
    Earth, located in Milky Way galaxy
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i uses VB6. thank you though i got from microsoft.com on how to do it.
    You must dream to be a succesful person, go to sleep... www.niumai.tk is my site

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    A simple way i use is to put a shortcut in the startup folder when the application is installing.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #5
    New Coder
    Join Date
    Apr 2004
    Location
    Earth, located in Milky Way galaxy
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    boss, anyone can delete that link anytime with ease. even by mistake! anyway i got what i'm looking for.thanx
    You must dream to be a succesful person, go to sleep... www.niumai.tk is my site


  •  

    Posting Permissions

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