Visual Basic - Ejecutar al arrancar windows 2000

Life is soft - evento anual de software empresarial
 
Vista:

Ejecutar al arrancar windows 2000

Publicado por Febles (33 intervenciones) el 21/09/2004 04:14:52
Hola flota...
El problema es que quiero que mí programa se esjecute al iniciar win 2000, es decir igual que si lo ubiera colocado en la tarea programada al iniciar windows, o que cuando lo ejecuten por primera vez estando en cualquier parte de la PC baya para esta tarea prograda, ¿ Existirá alguna forma, alguna APIS o algo para solucionar esto?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ejecutar al arrancar windows 2000

Publicado por Rei (6 intervenciones) el 21/09/2004 04:43:30
Te paso este código que me copie de este foro. Sirve para todos los Windows.

Option Explicit
DefLng A-Z

Public Const HKEY_CURRENT_USER As Long = &H80000001
Public Const HKEY_LOCAL_MACHINE As Long = &H80000002

Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition 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, ByVal lpData As String, ByVal cbData As Long) As Long

Private Const REG_SZ = 1
Private Const REG_OPTION_NON_VOLATILE = 0

Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const SYNCHRONIZE = &H100000

Private 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 Const ERROR_SUCCESS = 0&

Public Function ColocarProgramaEnElRun(ByVal NombrePrograma As String, ByVal RutaPrograma As String) As Boolean
Dim hdlHandle As Long, lngCreada As Long, strBuffer As String, lngBuffer As Long, Clave As String, hKey As Long
Clave = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
hKey = HKEY_CURRENT_USER '(Usuario corriente) HKEY_LOCAL_MACHINE (Todos los usuarios, la máquina)
strBuffer = RutaPrograma & vbNullChar
lngBuffer = Len(RutaPrograma) + 1
If RegCreateKeyEx(hKey, Clave, 0, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, hdlHandle, lngCreada) <> ERROR_SUCCESS Then GoTo NoReg
If RegSetValueEx(hdlHandle, NombrePrograma, 0, REG_SZ, strBuffer, lngBuffer) <> ERROR_SUCCESS Then GoTo NoReg
RegCloseKey hdlHandle
ColocarProgramaEnElRun = True
Exit Function
NoReg:
RegCloseKey hdlHandle
ColocarProgramaEnElRun = False
End Function

Rei
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ejecutar al arrancar windows 2000

Publicado por Febles (33 intervenciones) el 22/09/2004 04:33:59
Una pregunta si yo coloco este codigo en el evento Load del formulario es decir al abrir, mi programa se va a ejecutar cada ves que inicie windows.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar