debería, mira con el regedit a ver si se ha creado correctamente la clave
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
Set PorDefecto = CreateObject("WScript.Shell")
PorDefecto.regWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & app.EXEname, App.Path & "\" & App.EXEName & ".exe"
Set PorDefecto = CreateObject("WScript.Shell")
PorDefecto.regWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & app.EXEname, App.Path & "\" & App.EXEName & ".exe"
'DECLARACION DE APIS
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub timSeguridad_Timer()
'VARIABLES
Dim handle, Longitud, Retorno As Long
Dim Titulo As String
'IDENTIFICACION DE VENTANAS
handle = GetForegroundWindow()
Longitud = GetWindowTextLength(handle) + 1
Titulo = Space(Longitud)
Retorno = GetWindowText(handle, Titulo, Longitud)
Titulo = Left(Titulo, Longitud - 1)
If (Titulo <> UltimaVentana) And (Titulo <> "") Then
lstVentanas.AddItem (Titulo)
UltimaVentana = Titulo
If Comprobar(Titulo) = True Then
'SI CONTIENE PALABRAS PROHIBIDAS MANDAMOS LOS COMANDOS. CREA L FUNCION COMPROBAR QUE DIGA QUE SI EL TITULO ES "Administrador de tareas de Windows" QUE LA CIERRE
End If
End If
End Sub
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject _
As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Const PROCESS_TERMINATE = &H1
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ACTIVE = &H103
Public Sub CerrarProceso(CaptionVentana As String)
Dim hProceso As Long
Dim lEstado As Long
Dim idProc As Long
Dim winHwnd As Long
winHwnd = FindWindow(vbNullString, CaptionVentana)
If winHwnd = 0 Then
Exit Sub
End If
Call GetWindowThreadProcessId(winHwnd, idProc)
' Obtenemos el handle al proceso
hProceso = OpenProcess(PROCESS_TERMINATE Or _
PROCESS_QUERY_INFORMATION, 0, idProc)
If hProceso <> 0 Then
' Comprobamos estado del proceso
GetExitCodeProcess hProceso, lEstado
If lEstado = STILL_ACTIVE Then
' Cerramos el proceso
If TerminateProcess(hProceso, 9) <> 0 Then
Else
End If
End If
' Cerramos el handle asociado al proceso
CloseHandle hProceso
Else
Debug.Print "No se pudo tener acceso al proceso"
End If
End Sub
If comando(0) = "Cerrar" Then
CerrarProceso (comando(1))
End if
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Form_Load()
Dim I As Integer
Dim Est As String
Est = String$(50, " ")
I = GetPrivateProfileString("Ejemplo", "Nombre", "", Est, Len(Est), "Ejemplo.ini")
If I > 0 Then
MsgBox "Tu Nombre es: " & Est
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim I As Integer
Dim Est As String
Est = "Ejemplo - Apartado"
I = WritePrivateProfileString("Ejemplo", "Nombre", Est, "Ejemplo.ini")
End Sub
archivo = "C:\existe.txt"
existe = Len(Dir$(archivo))
If existe Then
MsgBox "El archivo existe"
Else
MsgBox "El archivo no existe"
End If