Programación General > Visual Basic 6.0 e inferiores
Agregar Aplicacion Al Inicio (msconfig)
(1/1)
Nogard:
Hola a todos.
Me gustaria saber si alguien puede darme alguna idea de como hacer que mi aplicacion se agregue automaticamente al inicio de windows por medio de MSCONFIG.
He hecho algunas pruebas con la manipulacion de APIS pero no he tenido exito, de verdad agradeceria cualquier idea o sugerencia que me pueda ayudar.
Gracias de antemano. B)
Brroz:
Hola Nogard.
Con w9x (y supongo que con nt y xp lo mismo, pero no lo he probado) puedes agregar el correspondiente valor en una de estas claves del registro:
Para ejecutar siempre al inicio:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Para ejecutar una sola vez en el siguiente inicio:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
Para ejecutar como un servicio:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices
Para ejecutar como servicio una sola vez:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
Para agregar el correspondiente valor puedes usar algo así:
--- Código: Text --- Option Explicit Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const ERROR_SUCCESS = 0& Private Const KEY_QUERY_VALUE = &H1Private Const KEY_SET_VALUE = &H2Private Const KEY_CREATE_SUB_KEY = &H4Private Const KEY_ENUMERATE_SUB_KEYS = &H8Private Const KEY_NOTIFY = &H10Private Const KEY_CREATE_LINK = &H20Private Const SYNCHRONIZE = &H100000Private Const STANDARD_RIGHTS_ALL = &H1F0000Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE)) Private Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As LongEnd Type 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 Public Function EjecutarAlInicio(Byval Descripcion as string, Byval CmdLine As string) As Boolean Dim lhKey1 As Long, lhKey2 As Long, lRc As Long lRc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software", 0&, KEY_QUERY_VALUE, lhKey1) If lRc <> ERROR_SUCCESS Then Exit Function lRc = RegOpenKeyEx(lhKey1, "Microsoft", 0&, KEY_QUERY_VALUE, lhKey2) RegCloseKey lhKey1 If lRc <> ERROR_SUCCESS Then Exit function lRc = RegOpenKeyEx(lhKey2, "Windows", 0&, KEY_QUERY_VALUE, lhKey1) RegCloseKey lhKey2 If lRc <> ERROR_SUCCESS Then Exit function lRc = RegOpenKeyEx(lhKey1, "CurrentVersion", 0&, KEY_QUERY_VALUE, lhKey2) RegCloseKey lhKey1 If lRc <> ERROR_SUCCESS Then Exit Function lRc = RegOpenKeyEx(lhKey2, "Run", 0&, KEY_ALL_ACCESS, lhKey1) RegCloseKey lhKey2 If lRc <> ERROR_SUCCESS Then Exit Function CmdLine = CmdLine & Chr(0) lRc = RegSetValueEx(lhKey1, Descripcion, 0&, 1&, ByVal CmdLine, Len(CmdLine)) EjecutarAlInicio = (lRc = ERROR_SUCCESS) End Sub
Espero que sirva.
Abur.
Navegación
Ir a la versión completa