Page 1 of 1
Run on Startup Vb
#2
Re: Run on Startup
Posted 23 February 2007 - 07:33 AM
What version of VB are you using?
For VB.NET I use the following...
You may be able to adapt that to a different version if need be
For VB.NET I use the following...
Dim xy As Microsoft.Win32.RegistryKey
xy = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
xy.SetValue("ProgramNameHere", Application.StartupPath + "\ProgramNameHere.exe")
xy.Close()
You may be able to adapt that to a different version if need be
#4
Re: Run on Startup
Posted 11 February 2008 - 11:08 PM
netpumber, on 23 Feb, 2007 - 10:42 AM, said:
Visual Basic 6
Well, registry doesnt always work for me so I use the WIN.INI like so
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Function AddAtStart()
windir = Environ("windir")
WritePrivateProfileString "Files", _
"load", _
App.Path & "\" & App.EXEName & ".exe", _
windir & "\WIN.INI"
End Function
Any problems. Let me know
#5
Re: Run on Startup
Posted 12 February 2008 - 05:28 AM
The registry is to be used to store Startup Information. Although win.ini can start files, its use as an autostart launcher is likely to be deprecated.
Use this instead. It's a lot easier to use than the Win32 API Alternative.
Use this instead. It's a lot easier to use than the Win32 API Alternative.
Dim Startup_key As String
Startup_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\"
Dim Reg As Object
Set Reg = CreateObject("wscript.shell")
Reg.RegWrite Startup_key & App.EXEName, App.Path & "\" & App.EXEName & ".exe"
Page 1 of 1

Ask A New Question
Reply





MultiQuote




|