esperanza28 de Octubre del 2002
Pregunta Estimados amigos, he ejecutado el ejemplo de msdn.microsoft para ejecutar la aplicación Notepad desde un programa en VB y me da error de compilación: Variable no definida. El programa lo he copiado tal cual con el portapapeles:
Option Explicit
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 Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
'3. Add a Command Button control to Form1. Command1 is created by default.
'4. Add the following code to the Click event for Command1:
Private Sub Command1_Click()
Dim JobToDo As String
JobToDo = "c:windowsnotepad.exe"
Shell32Bit JobToDo
End Sub
'5. Create a new subroutine called Shell32Bit. Add the following code to this subroutine:
Sub Shell32Bit(ByVal JobToDo As String)
Dim hProcess As Long
Dim RetVal As Long
'The next line launches JobToDo as icon,
'captures process ID
hProcess = OpenProcess
'Aquí me da el error, en la variable Flase. La
'verdad es que no se de donde sale
'
(PROCESS_QUERY_INFORMATION, Flase, Shell(JobToDo, 6))
Do
'Get the status of the process
GetExitCodeProcess hProcess, RetVal
'Sleep command recommended as well
'as DoEvents
DoEvents: Sleep 100
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE
MsgBox "Notepad terminated by user"
End Sub
Me gustaría que me funcionara,pero no se como hacerlo. Gracias de antemano.
Option Explicit
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 Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
'3. Add a Command Button control to Form1. Command1 is created by default.
'4. Add the following code to the Click event for Command1:
Private Sub Command1_Click()
Dim JobToDo As String
JobToDo = "c:windowsnotepad.exe"
Shell32Bit JobToDo
End Sub
'5. Create a new subroutine called Shell32Bit. Add the following code to this subroutine:
Sub Shell32Bit(ByVal JobToDo As String)
Dim hProcess As Long
Dim RetVal As Long
'The next line launches JobToDo as icon,
'captures process ID
hProcess = OpenProcess
'Aquí me da el error, en la variable Flase. La
'verdad es que no se de donde sale
'
(PROCESS_QUERY_INFORMATION, Flase, Shell(JobToDo, 6))
Do
'Get the status of the process
GetExitCodeProcess hProcess, RetVal
'Sleep command recommended as well
'as DoEvents
DoEvents: Sleep 100
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE
MsgBox "Notepad terminated by user"
End Sub
Me gustaría que me funcionara,pero no se como hacerlo. Gracias de antemano.
