Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Ejecutar DOS en Ventana Windows (https://www.clubdelphi.com/foros/showthread.php?t=77798)

MAXIUM 27-02-2012 01:39:41

Ejecutar DOS en Ventana Windows
 
Parecerá un tema repetido, pero lo cierto es que busco algo en tiempo real. Es decir, al ejecutar un comando DOS, aparece el resultado en el memo pero cuando ya esta todo el proceso finalizada y no muestra todos los pasos.

Por ejemplo al ejecutar chkdsk

http://www.ajpdsoft.com/modules.php?...rticle&sid=442

delphi.com.ar 27-02-2012 02:59:17

Yo hace muuuucho hice algo así, no tengo el código pero recuerdo que hacía lo que dicen estos hilos:

http://www.clubdelphi.com/foros/show...06&postcount=2
http://www.clubdelphi.com/foros/show...04&postcount=2

Y luego obtenía el buffer de la consola para mostrarlo en pantalla.

Saludos!

MAXIUM 28-02-2012 01:18:39

Lo más cercano que encontré

Código Delphi [-]
procedure RunDosInMemo( CmdLine: string; AMemo: TMemo );
const
  ReadBuffer = 2400;
var
  Security: TSecurityAttributes;
  ReadPipe, WritePipe: THandle;
  start: TStartUpInfo;
  ProcessInfo: TProcessInformation;
  Buffer: Pchar;
  BytesRead: DWord;
  Apprunning: DWord;
begin
   Screen.Cursor := CrHourGlass;
   with Security do
   begin
      nlength := SizeOf( TSecurityAttributes );
      binherithandle := true;
      lpsecuritydescriptor := nil;
   end;
   if Createpipe( ReadPipe, WritePipe, @Security, 0 ) then
   begin
      Buffer := AllocMem( ReadBuffer+1 );
      FillChar( Start, Sizeof( Start ), #0 );
      start.cb := SizeOf( start );
      start.hStdOutput := WritePipe;
      start.hStdInput := ReadPipe;
      start.dwFlags := STARTF_USESTDHANDLES + STARTF_USESHOWWINDOW;
      start.wShowWindow := SW_HIDE;
      if CreateProcess( nil, PChar( CmdLine ), @Security, @Security, true,
                        NORMAL_PRIORITY_CLASS, nil, nil,  start, ProcessInfo ) then
      begin
         repeat
            Apprunning := WaitForSingleObject( ProcessInfo.hProcess, 100 );
            ReadFile( ReadPipe, Buffer[0], ReadBuffer, BytesRead, nil );
            Buffer[BytesRead] := #0;
            OemToAnsi( Buffer, Buffer );
            AMemo.Text := AMemo.text + string( Buffer );
            Application.ProcessMessages;
         until ( Apprunning <> WAIT_TIMEOUT );
      end;
      FreeMem( Buffer );
      CloseHandle( ProcessInfo.hProcess );
      CloseHandle( ProcessInfo.hThread );
      CloseHandle( ReadPipe );
      CloseHandle( WritePipe );
   end;
   Screen.Cursor := CrDefault;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
   Memo1.Clear;
   Button1.Enabled := false;
   RunDosInMemo( 'ping 127.0.0.1', Memo1 );
   // RunDosInMemo( 'net send 127.0.0.1 Привет', Memo1 );
   Button1.Enabled := true;
end;

Neeruu 28-02-2012 20:32:09

Ejecutar DOS en Ventana Windows
 
Hola a todos...

Hay un componente que hace eso....

Se llama TDosCommand....

http://maxxdelphisite.free.fr/doscmd.htm

Saluda Atte Neeruu!!!:)

MAXIUM 29-02-2012 02:28:05

Hey, es excelente. Muchas gracias ;)

escafandra 29-02-2012 08:24:09

Puedes revisar ésto, en caso de que no te interesen componentes.


Saludos.


La franja horaria es GMT +2. Ahora son las 14:21:20.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi