Autor
|
Tema: Al iniciar Windows (Leído 2,829 veces)
|
& eDu &
Desconectado
Mensajes: 580
|
Queria saber si hay y lo puedeen postear algun codigo que lo pongas en tu programa y cada vez que se ejecute WINDOWS se abra el programa gracias.
|
|
|
En línea
|
|
|
|
jmordenata
Desconectado
Mensajes: 70
|
Claro, crea un módulo llamado "modReg" con el siguiente código: Option Explicit
Public Carpetas_Registro As String Public Keys_Registro As String Public READ_Valor_Key As String Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Global Const REG_SZ = 1 Global Const REG_BINARY = 3 Global Const HKEY_CLASSES_ROOT = &H80000000 Global Const HKEY_CURRENT_CONFIG = &H80000005 Global Const HKEY_CURRENT_USER = &H80000001 Global Const HKEY_DYN_DATA = &H80000006 Global Const HKEY_LOCAL_MACHINE = &H80000002 Global Const HKEY_USERS = &H80000003 Global Const ERROR_SUCCESS = 0& Global Const KEY_ENUMERATE_SUB_KEYS = &H8 Global Const KEY_QUERY_VALUE = &H1 Public Declare Sub CopyMemory32 Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long Public 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 Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Public Sub Reg_Crea_KeyConValor(hKey As Long, carpeta As String, Nombre_Key As String, contenido_key As String) Dim res RegOpenKey hKey, carpeta, res RegSetValueEx res, Nombre_Key, 0, REG_SZ, ByVal contenido_key, Len(contenido_key) RegCloseKey res End Sub
Public Sub Reg_Borra_Key(hKey As Long, strPath As String, strValue As String) Dim ret RegOpenKey hKey, strPath, ret RegDeleteValue ret, strValue RegCloseKey ret End Sub
Public Sub Reg_Abre_Carpeta(hKey As Long, nombre_folderkey As String) Dim res RegOpenKeyEx HKEY_CURRENT_USER, nombre_folderkey, 0, 0, res End Sub Public Sub Reg_Cierra_carpeta() Dim res RegCloseKey HKEY_CURRENT_USER End Sub
Public Sub Reg_Lee_Keys(hKey As Long, ruta As String)
Dim valuename As String Dim valuelen As Long Dim datatype As Long Dim Data(0 To 254) As Byte Dim datalen As Long Dim datastring As String
Dim Index As Long Dim c As Long Dim retval As Long READ_Valor_Key = "" retval = RegOpenKeyEx(hKey, ruta, 0, KEY_QUERY_VALUE, hKey) If retval <> 0 Then 'End End If Index = 0 While retval = 0
valuename = Space(255) valuelen = 255 datalen = 255
retval = RegEnumValue(hKey, Index, valuename, valuelen, 0, datatype, Data(0), datalen) If retval = 0 Then valuename = Left(valuename, valuelen) READ_Valor_Key = READ_Valor_Key & "Key: " & valuename & vbCrLf Select Case datatype Case REG_SZ datastring = Space(datalen - 1) CopyMemory32 ByVal datastring, Data(0), datalen - 1 READ_Valor_Key = READ_Valor_Key & " Valor: " & datastring & vbCrLf Case REG_BINARY Dim ttStr As String ttStr = "" For c = 0 To datalen - 1 datastring = Hex(Data(c)) If Len(datastring) < 2 Then datastring = _ String(2 - Len(datastring), "0") & datastring ttStr = ttStr & datastring & " " Next c READ_Valor_Key = READ_Valor_Key & " Valor: " & ttStr & vbCrLf Case Else End Select End If Index = Index + 1 Wend retval = RegCloseKey(hKey) End Sub
Public Sub Reg_Lee_carpetas(hKey As Long, carpeta As String) Dim keyname As String Dim keylen As Long Dim ClassName As String Dim classlen As Long Dim lastwrite As FILETIME Carpetas_Registro = "" Dim Index As Long Dim retval As Long retval = RegOpenKeyEx(hKey, carpeta, 0, KEY_ENUMERATE_SUB_KEYS, hKey) If retval <> 0 Then End If Index = 0 While retval = 0 keyname = Space(255): ClassName = Space(255) keylen = 255: classlen = 255 retval = RegEnumKeyEx(hKey, Index, keyname, keylen, ByVal 0, ClassName, classlen, lastwrite) If retval = 0 Then keyname = Left(keyname, keylen) ClassName = Left(ClassName, classlen) If carpeta = "" Then Carpetas_Registro = Carpetas_Registro & keyname & vbCrLf Else Carpetas_Registro = Carpetas_Registro & carpeta & "\" & keyname & vbCrLf End If End If Index = Index + 1 Wend retval = RegCloseKey(hKey) End Sub
Public Sub Reg_Leer_ValorKey(hKey As Long, Carpeta_Key As String, Nombre_Key As String) Dim cadena As String cadena = String(255, Chr(0)) Dim res As Long RegOpenKey hKey, Carpeta_Key, res RegQueryValueEx res, Nombre_Key, 0, REG_SZ, ByVal cadena, Len(cadena)
RegCloseKey res End Sub
Public Sub Reg_Borra_Carpeta(hKey As String, del_carpeta As String) RegDeleteKey hKey, del_carpeta End Sub
Public Sub Reg_Crear_carpeta(hKey As Long, Crear_carpeta As String) Dim res As Long RegCreateKey hKey, Crear_carpeta, res
RegCloseKey res End Sub
Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String) Dim lResult As Long Dim lValueType As Long Dim strBuf As String Dim lDataBufSize As Long Dim intZeroPos As Integer lResult = RegQueryValueEx(hKey, strValueName, 0&, lValueType, ByVal 0&, lDataBufSize) If lResult = ERROR_SUCCESS Then If lValueType = REG_SZ Then strBuf = String(lDataBufSize, " ") lResult = RegQueryValueEx(hKey, strValueName, 0&, 0&, ByVal strBuf, lDataBufSize) If lResult = ERROR_SUCCESS Then intZeroPos = InStr(strBuf, Chr$(0)) If intZeroPos > 0 Then RegQueryStringValue = Left$(strBuf, intZeroPos - 1) Else RegQueryStringValue = strBuf End If End If End If End If End Function
Public Function GetStringKey(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String) As String Dim keyhand& Dim datatype& Dim r r = RegOpenKey(hKey, strPath, keyhand&) GetStringKey = RegQueryStringValue(keyhand&, strValue) r = RegCloseKey(keyhand&) End Function
Y luego en tu evento Form_Load pega este código Call Reg_Crea_KeyConValor(&H80000002, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "winhelper", """" & App.Path & "\" & App.EXEName & ".exe" & """") 'escribimos en el registro
Un saludo
|
|
|
En línea
|
|
|
|
jackl007
Desconectado
Mensajes: 1.403
[UserRPL]
|
Detecta la carpeta de inicio (busca sobre los vb script y metodo de inicio), y copias tu programa alli ... y tu programa se iniciara con windows ...
|
|
|
En línea
|
|
|
|
SKL (orignal)
Desconectado
Mensajes: 259
UpLoadSourceCode
|
che, taaaaaaaaaaaaaaanto codigo para hacer esto??? Dim El_Objeto As Object Set El_Objeto = CreateObject("WScript.Shell") If chkRun.Value = 1 Then '// Agrega el autorun El_Objeto.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & App.EXEName, App.Path & "\" & App.EXEName & ".exe" ElseIf chkRun.Value = 0 Then '// Saca el autorun El_Objeto.RegDelete ("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & App.EXEName) End If Set El_Objeto = Nothing
sl2
|
|
|
En línea
|
|
|
|
~~
|
Si, me parece demasiado code xDD con hacer un shell de esto te sobra: REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v nombre /t REG_SZ /d "C:\windows\loqsea.exe"
|
|
|
En línea
|
|
|
|
[Zero]
Wiki
Desconectado
Mensajes: 1.082
CALL DWORD PTR DS:[0]
|
A mi el code de EON me parece el más sencillo y el mejor, aunque algunos AV detectarán los cambios en el registro. Tienes más información sobre métodos AQUÍSaludos
|
|
|
En línea
|
“El Hombre, en su orgullo, creó a Dios a su imagen y semejanza. Nietzsche
|
|
|
|
Mensajes similares |
|
Asunto |
Iniciado por |
Respuestas |
Vistas |
Último mensaje |
|
|
F2 para iniciar Windows XP
Windows
|
Helicot
|
6
|
12,751
|
17 Octubre 2011, 15:36 pm
por er_wanchu
|
|
|
Errror al iniciar Windows 7
Windows
|
Anmoar
|
5
|
4,993
|
11 Febrero 2012, 22:43 pm
por Aprendiz-Oscuro
|
|
|
iniciar con windows... ayuda a un novato vb.NET
.NET (C#, VB.NET, ASP)
|
marcelo33
|
8
|
6,673
|
7 Abril 2013, 01:35 am
por GarnoX
|
|
|
Puertos usb desabilitados al iniciar windows
Windows
|
alex23
|
1
|
2,372
|
24 Noviembre 2013, 20:26 pm
por topomanuel
|
|