elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Modulo StartUp ["AutoRun.bas"] Falla
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Modulo StartUp ["AutoRun.bas"] Falla  (Leído 2,755 veces)
agus0


Desconectado Desconectado

Mensajes: 360



Ver Perfil
Modulo StartUp ["AutoRun.bas"] Falla
« en: 5 Noviembre 2010, 02:17 am »

Hola Gente Dando vueltas por Internet me encontré con este modulo que Creo que es de Leandro Ascierto. Y a la hora de usarlo Falla, pero me pareció averla usado antes. quería saber si alguien me puede corroborar si le funciona o no lo que pasa es que yo ahora cambie de S.O a W$7.

Gracias.

Código
  1. Option Explicit
  2.  
  3. 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
  4. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  5. Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
  6. Private Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String)
  7. Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
  8. Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
  9. Private Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String)
  10.  
  11. Private Const RAMA_RUN_WINDOWS As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
  12. Private Const HKEY_CLASSES_ROOT = &H80000000
  13. Private Const HKEY_CURRENT_USER = &H80000001
  14. Private Const HKEY_LOCAL_MACHINE = &H80000002
  15. Private Const HKEY_USERS = &H80000003
  16. Private Const REG_SZ As Long = 1
  17. Private Const KEY_ALL_ACCESS = &H3F
  18.  
  19.  
  20. Public Function SetAutoRun(Value As Boolean) As Boolean
  21.  
  22.    Dim Path          As String
  23.    Dim Handle        As Long
  24.  
  25.    Path = Chr(34) & App.Path & "\" & App.EXEName & ".exe" & Chr(34)
  26.  
  27.    RegOpenKeyEx HKEY_CURRENT_USER, RAMA_RUN_WINDOWS, 0, KEY_ALL_ACCESS, Handle
  28.    If Value Then
  29.        SetAutoRun = RegSetValueExString(Handle, App.Title, 0&, REG_SZ, Path, Len(Path)) = 0
  30.    Else
  31.        SetAutoRun = RegDeleteValue(Handle, App.Title) = 0
  32.    End If
  33.    RegCloseKey Handle
  34.  
  35. End Function
  36.  
  37.  
  38. Public Function IsAutoRun() As Boolean
  39.  
  40.    Dim Path          As String
  41.    Dim Handle        As Long
  42.    Dim Data          As String
  43.    Dim cch           As Long
  44.  
  45.    Path = Chr(34) & App.Path & "\" & App.EXEName & ".exe" & Chr(34)
  46.  
  47.    RegOpenKeyEx HKEY_CURRENT_USER, RAMA_RUN_WINDOWS, 0, KEY_ALL_ACCESS, Handle
  48.    RegQueryValueExNULL Handle, App.Title, 0&, 0&, 0&, cch
  49.  
  50.    If cch > 0 Then
  51.        Data = String(cch - 1, 0)
  52.        RegQueryValueExString Handle, App.Title, 0&, 0&, Data, cch
  53.        IsAutoRun = Path = Data
  54.    End If
  55.  
  56.    RegCloseKey Handle
  57.  
  58. End Function


En línea

_katze_

Desconectado Desconectado

Mensajes: 140



Ver Perfil WWW
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #1 en: 5 Noviembre 2010, 03:45 am »

si iinicias tu aplicacion como administrador te tiene q funcionar ! igual creo q deberias buscar tu propia manera ya q como sabes desde W$ vista en adelante tenes el UAC y demas !


En línea

agus0


Desconectado Desconectado

Mensajes: 360



Ver Perfil
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #2 en: 5 Noviembre 2010, 04:06 am »

Buenas... Probé abriendo la aplicación como administrador y no funciono.
tengo mi manera de hacerlo pero esta me gusto mas... es mas corta jaja.
me parece no estoy seguro que la dirección donde se guarda en el inicio los programas que se cargan con Win7 no es igual al de los anteriores...

Gracias
En línea

raul338


Desconectado Desconectado

Mensajes: 2.633


La sonrisa es la mejor forma de afrontar las cosas


Ver Perfil WWW
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #3 en: 5 Noviembre 2010, 04:17 am »

MM... ahora no tengo tiempo de fijarme, pero te dejo mi copia del modulo de leandro que si funciona, lo que pasa es que ahora la pagina de leandroA esta caida, siempre es bueno guardarse una copia offline xD

Código
  1. Option Explicit
  2. ' http://www.leandroascierto.com.ar/categoria/M%C3%B3dulos/articulo/Inicio%20Aplicaci%C3%B3n%20con%20Windows.php
  3. 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
  4. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  5. Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
  6. Private Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String)
  7. Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
  8. Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
  9. Private Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String)
  10.  
  11. Private Const RAMA_RUN_WINDOWS As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
  12. Private Const HKEY_CLASSES_ROOT = &H80000000
  13. Private Const HKEY_CURRENT_USER = &H80000001
  14. Private Const HKEY_LOCAL_MACHINE = &H80000002
  15. Private Const HKEY_USERS = &H80000003
  16. Private Const REG_SZ As Long = 1
  17. Private Const KEY_ALL_ACCESS = &H3F
  18.  
  19.  
  20. Public Function SetAutoRun(value As Boolean) As Boolean
  21.  
  22.    Dim Path          As String
  23.    Dim handle        As Long
  24.  
  25.    Path = Chr(34) & App.Path & "\" & App.EXEName & ".exe" & Chr(34)
  26.  
  27.    RegOpenKeyEx HKEY_CURRENT_USER, RAMA_RUN_WINDOWS, 0, KEY_ALL_ACCESS, handle
  28.    If value Then
  29.        SetAutoRun = RegSetValueExString(handle, App.Title, 0&, REG_SZ, Path, Len(Path)) = 0
  30.    Else
  31.        SetAutoRun = RegDeleteValue(handle, App.Title) = 0
  32.    End If
  33.    RegCloseKey handle
  34.  
  35. End Function
  36.  
  37.  
  38. Public Function IsAutoRun() As Boolean
  39.  
  40.    Dim Path          As String
  41.    Dim handle        As Long
  42.    Dim Data          As String
  43.    Dim cch           As Long
  44.  
  45.    Path = Chr(34) & App.Path & "\" & App.EXEName & ".exe" & Chr(34)
  46.  
  47.    RegOpenKeyEx HKEY_CURRENT_USER, RAMA_RUN_WINDOWS, 0, KEY_ALL_ACCESS, handle
  48.    RegQueryValueExNULL handle, App.Title, 0&, 0&, 0&, cch
  49.  
  50.    If cch > 0 Then
  51.        Data = String(cch - 1, 0)
  52.        RegQueryValueExString handle, App.Title, 0&, 0&, Data, cch
  53.        IsAutoRun = Path = Data
  54.    End If
  55.  
  56.    RegCloseKey handle
  57.  
  58. End Function
  59.  
« Última modificación: 5 Noviembre 2010, 13:43 pm por raul338 » En línea

agus0


Desconectado Desconectado

Mensajes: 360



Ver Perfil
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #4 en: 5 Noviembre 2010, 04:39 am »

Gracias Raul. Si esta caída por desgracia :S ahora me voy a dormir mañana me fijo. Gracias!!
En línea

agus0


Desconectado Desconectado

Mensajes: 360



Ver Perfil
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #5 en: 5 Noviembre 2010, 21:31 pm »

Raul, Mira probé el código y tampoco funciona, ejecute la App como admin y tampoco puede ser que W$7 Guarde las Claves de Inicio en otra parte del registro?
En línea

LeandroA
Moderador
***
Desconectado Desconectado

Mensajes: 760


www.leandroascierto.com


Ver Perfil WWW
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #6 en: 5 Noviembre 2010, 22:27 pm »

Hola ami en w7 me funciona bien, por las dudas como se llama tu proyecto, tiene espacios dentro del nombre?, en donde lo guardas, lo ejecutaste al menos una vez como para que se ejecute la linea SetAutoRun = true?

te fijaste si se escrivio en el registro en la clave
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

saludos.
En línea

raul338


Desconectado Desconectado

Mensajes: 2.633


La sonrisa es la mejor forma de afrontar las cosas


Ver Perfil WWW
Re: Modulo StartUp ["AutoRun.bas"] Falla
« Respuesta #7 en: 6 Noviembre 2010, 00:32 am »

A mi me funciona, me escribe en el registro :-\
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
StartUp Manager
GNU/Linux
VIPbie 5 3,056 Último mensaje 11 Junio 2011, 12:58 pm
por Slava_TZD
Recuadro "startup repair"
Windows
Schiffer04 1 2,707 Último mensaje 11 Mayo 2012, 13:03 pm
por Eleкtro
Palantir, la 'startup' de la CIA para plantarle cara al "eje del mal"
Noticias
wolfbcn 0 1,131 Último mensaje 9 Diciembre 2013, 01:02 am
por wolfbcn
¿Sacar modulo de un numero sin "%"?
Programación C/C++
meaf75 1 1,632 Último mensaje 17 Febrero 2017, 18:11 pm
por engel lex
"Nos han robado 31 millones de dólares en criptomonedas", asegura una startup...
Noticias
wolfbcn 4 2,093 Último mensaje 21 Noviembre 2017, 20:43 pm
por engel lex
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines