01-22-2005, 08:03 AM
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
01-23-2005, 05:53 AM
VB...what? .net? 6? 7?
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
Select Case ParentKeyHive
objParentKey = Registry.ClassesRoot
objParentKey = Registry.CurrentConfig
objParentKey = Registry.CurrentUser
objParentKey = Registry.DynData
objParentKey = Registry.LocalMachine
objParentKey = Registry.PerformanceData
objParentKey = Registry.Users
'Open Registry Key
objSubKey = objParentKey.OpenSubKey(SubKeyName, True)
'create if doesn't exist
If objSubKey Is Nothing Then
objSubKey = objParentKey.CreateSubKey(SubKeyName)
Catch ex As Exception
boolReturn = False
Note that I borrowed some code found here (http://www.freevbcode.com/ShowCode.asp?ID=174), cleaned it up, and added the appropriate registry key.
01-30-2005, 08:06 AM
i uses VB6. thank you though i got from microsoft.com on how to do it.
01-31-2005, 08:29 AM
A simple way i use is to put a shortcut in the startup folder when the application is installing.
02-01-2005, 09:17 AM
boss, anyone can delete that link anytime with ease. even by mistake! anyway i got what i'm looking for.thanx