Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Hacer ping con ShellExecute (https://www.clubdelphi.com/foros/showthread.php?t=80860)

calogero 17-04-2008 23:49:12

Hacer ping con ShellExecute
 
Nota:
Solo tienes que introducir la IP, en la caja de texto
y presionar Enter.

..dejen sus comentarios, gracias :')



Código Delphi [-]
type
  TForm1 = class(TForm)
    eDirIP: TEdit;
    Label1: TLabel;
    btnPing: TButton;
    procedure btnPingClick(Sender: TObject);
    procedure eDirIPKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnPingClick(Sender: TObject);
var
  Archivo: TextFile;
begin
  // creamos el archivo .bat
  AssignFile(Archivo, 'c:\ping.bat');
  {$i-} Rewrite(Archivo); {$i+} // lo sobreescribimos
  if LongBool(IOResult) then
  begin
   ShowMessage('Error al guardar.');
   Exit;
  end;

  // instrucciones para el archivo bat
  WriteLn(Archivo, '@echo off');
  WriteLn(Archivo, 'ping ' + eDirIP.Text);
  WriteLn(Archivo, 'pause');
  CloseFile(Archivo);

  // ejecutamos el bat
  ShellExecute(Form1.Handle, nil, 'c:\ping.bat',
  nil, nil, SW_SHOWNORMAL);
end;

procedure TForm1.eDirIPKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = VK_RETURN) then
    btnPing.Click;
end;

end.

Espero les sirva...

pfalzate 09-06-2008 17:27:08

Debe adicionar ShellAPI en USES

jeremiselxi 14-10-2008 13:05:16

oye este codigo es jevi. sigue asi mi hermano. Dios te bendiga, me ayudo este codigo. ahora tambien podre ayudar a otro tambien.


La franja horaria es GMT +2. Ahora son las 18:18:47.

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