|
-
Dec 1st, 2003, 02:29 PM
#1
Thread Starter
Addicted Member
Run when computer starts?
how would i run the application as soon as the user starts their computer?
-
Dec 1st, 2003, 02:31 PM
#2
Frenzied Member
Put a shortcut in the startup. This can be done during setup. It should be in your deployment wizard and if it's not, change what you use to create your setup files.
-
Dec 1st, 2003, 02:32 PM
#3
Frenzied Member
You could either put a shortcut to your program in the Startup folder in the start menu, or you could use the registry here
Code:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
-
Dec 1st, 2003, 02:33 PM
#4
Frenzied Member
Heh, beat me to it
-
Dec 1st, 2003, 02:36 PM
#5
Frenzied Member
lpeek, please stop asking your questions in new threads when they have already been answered in other threads. This is both rude and annoying. If something doesn't get fully answered, bump your old thread. Do not create a new one. That adds clutter to the boards.
-
Dec 1st, 2003, 02:49 PM
#6
Hyperactive Member
If you wanna do it via code...
In a module:
VB Code:
Option Explicit
Public Const REG_SZ = 1
Public Const HKEY_CURRENT_USER = &H80000001
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public 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
Public 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
Public Sub SaveSettingString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim hCurKey As Long
Dim lRegResult As Long
lRegResult = RegCreateKey(hKey, strPath, hCurKey)
lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, ByVal strData, Len(strData))
lRegResult = RegCloseKey(hCurKey)
End Sub
In your form:
VB Code:
Private Sub Form_Load()
Dim sAppEXE As String
sAppEXE = App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & App.EXEName & ".exe"
SaveSettingString HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", App.Title, Chr$(34) & sAppEXE & Chr$(34)
End Sub
There's an API method of returning the exact executeable path\filename of an application and it's more robust than the method I used so I recommened it if you've got the time.
-adehh
-
Dec 1st, 2003, 04:16 PM
#7
Thread Starter
Addicted Member
the bits that say:
Public Const REG_SZ = 1
Public Const HKEY_CURRENT_USER = &H80000001
Are in red and say:
Constants are not allowed as public members of object modules
-
Dec 1st, 2003, 04:29 PM
#8
10 aussie dollars that you didn't put that portion of code in a Module like adzzzz said 
If there in a Form - use Private!
Bruce.
-
Dec 1st, 2003, 04:30 PM
#9
Hold on a second. Are you asking how to start an app when Windows loads up, or when the computer is turned on?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|