¿Iniciar aplicacion vb6 con windows?

Iniciado por Buggcon, 2 Abril 2013, 21:30 PM

0 Miembros y 1 Visitante están viendo este tema.

Buggcon

Quisiera saber como hacer para que mi aplicacion se inicie con windows, me podrian psar algun codigo para vb6?

Muchas gracias amig@s  ;D

antraXactive

#1
Primero haces estas declaraciones
Código (vb) [Seleccionar]

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
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
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_WRITE = &H20006
Private Const REG_SZ = 1


Y luego la funcion que lo añadiría tendría esto
Código (vb) [Seleccionar]

Dim clave As Long
Dim subclave As String
Dim ruta As String
Dim retval As Long

ruta = App.Path & "\" & App.EXEName & ".exe" & vbNullChar
subclave = "Software\Microsoft\Windows\CurrentVersion\Run"
retval = RegOpenKeyEx(HKEY_CURRENT_USER, subclave, 0, KEY_WRITE, clave)
retval = RegOpenKeyEx(HKEY_CURRENT_USER, subclave, 0, KEY_WRITE, clave)
retval = RegSetValueEx(clave, "MiAplicacion", 0, REG_SZ, ByVal ruta, Len(ruta))
RegCloseKey (clave)