Buenas noches a todos¡
Los molesto con unas consultas ...
Estoy desarrollando una aplicacion que utiliza la funcion WinExecAndWait32 para ejecutar tres comandos
Los ejecuta sin problemas, el tema es que abre la ventanda de linea de comandos (cmd.exe) fuera del formulario
La idea por el momento es poder "capturar" la ventana con sus respectivos comandos y poder verlos en un Panel
Me refiero a poder ver la ventana cmd en el panel ya que dos comandos necesitan el ingreso de datos
La funcion que utilizo es la siguiente :
function WinExecAndWait32(Path: PChar; Visibility: Word; Timeout : DWORD): integer; function WinExecAndWait32(Path: PChar; Visibility: Word; Timeout : DWORD): integer; var WaitResult : integer; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; //iResult : integer; begin FillChar(StartupInfo, SizeOf(TStartupInfo), 0); with StartupInfo do begin cb := SizeOf(TStartupInfo); dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK; { you could pass sw_show or sw_hide as parameter: } wShowWindow := visibility; end; if CreateProcess(nil,path,nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then begin WaitResult := WaitForSingleObject(ProcessInfo.hProcess, timeout); { timeout is in miliseconds or INFINITE if you want to wait forever } result := WaitResult; end else { error occurs during CreateProcess see help for details } result:=GetLastError; end;
y para ejecutar los comandos por el momento me manejo con este codigo
var ComandoUno: string; ComandoDos: string; ComandoTres: string; begin ComandoUno:=('ping localhost'); WinExecAndWait32(pchar(ComandoUno),SW_SHOW,INFINITE); ComandoDos:=('dir c:'); WinExecAndWait32(pchar(ComandoDos),SW_SHOW,INFINITE); ComandoTres:=('netstat -a'); WinExecAndWait32(pchar(ComandoTres),SW_SHOW,INFINITE); end;
Desde ya muchas gracias por las respuestas u orientacion al respecto
Saludos¡