Visual Basic - Corren App.Con WIndows

Life is soft - evento anual de software empresarial
 
Vista:

Corren App.Con WIndows

Publicado por Luis (2 intervenciones) el 03/09/2004 15:14:46
Hola que tal,primero que nada les doy las gracias por tomarse la molestia de leer la pregunta de su humilde servidor,mi pregunta es la siguiente,¿como puedo hacer,que mi aplicacion corra junto con windows al iniciarse,sin usar ninguna libreria?esto se los comento por que solo puedo hacer que corra con librerias .ocx,pero quiero que mi programa use las menos librerias que se puedan.

No importa si necesito agregar un modulo o algo,si alguien tiene el codigo para poder hacer eso sin librerias,le agradeceria mucho que me lo dijiera.Gracias
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:Corren App.Con WIndows

Publicado por Mr. Sade (322 intervenciones) el 03/09/2004 23:01:04
metes la ruta de tu programa al registro.
como por ejemplo a:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
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:Corren App.Con WIndows

Publicado por Luis (2 intervenciones) el 04/09/2004 04:22:55
Pero la cuestion es como meter la ruta del programa, lo que quiere es que por ejemplo al cargar el formulario principal automaticamente agregue esa rama al registro, no que yo lo tenga que hacer manualemente.Por que como te digo encontre un .ocx,pero pues creo que seria agregarle mas librerias al proyecto.

Si me pueden ayudar se los agradeceria.Gracias
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:Corren App.Con WIndows

Publicado por Ruri (583 intervenciones) el 04/09/2004 08:08:16
Luis:
Probá este código

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

Saludos Ruri
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