Hmm, it can't handle multiple line stdout :
-----------------------------------------------
unit main;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
interfaceuses
 
mseglob,mseapplication,mseclasses,msedatamodules,msepipestream,mseprocess,msestrings;

type
 tmainmo = class(tmsedatamodule)   process: tmseprocess;
   procedure pipebrokenexe(const sender: tpipereader);
   procedure inputavailexe(const sender: tpipereader);
   procedure loadedexe(const sender: TObject);
   procedure finished(const sender: TObject);
 end;

var
 mainmo: tmainmo;
 output: msestringarty;

implementation

uses
  main_mfm,msesysintf,sysutils,msearrayutils,{$ifdef mswindows}windows{$endif};

procedure tmainmo.pipebrokenexe(const sender: tpipereader);
begin
  exitcode:= 1;
  application.terminated:= true;
end;

procedure tmainmo.inputavailexe(const sender: tpipereader);
var
 str1: string;
begin
 if sender.readstrln(str1) then begin
   additem(output,str1);
   writeln(str1); end;
end;

procedure tmainmo.loadedexe(const sender: TObject);
begin  process.filename:= 'route print';
  process.active:= true;
end;

procedure tmainmo.finished(const sender: TObject);
var
  ar1: msestringarty;
  int1,i:integer;  info: osversioninfo;
  gwname: msestring;

begin info.dwOSVersionInfoSize:= sizeof(info);
 if not getversionex(info) then begin  application.terminated:= true; end;
 if not (info.dwmajorversion in [4,6]) then begin
        writeln('unsupported OS version: ', info.dwmajorversion);
    exitcode:= 1;
        application.terminated:= true;
 end; for i:= 0 to high(output) do begin    ar1:= splitstring(output[i],' ');
    if (ar1[0] = '255.255.255.255') and (ar1[0] = ar1[1]) then begin
      exitcode:= 0;
      if info.dwmajorversion = 4 then begin
        if (ar1[2] = ar1[3]) and (ar1[3] <> '127.0.0.1') then begin
          writeln(ar1[3]);
        end;
      end else
      if info.dwmajorversion = 6 then begin
        if (ar1[2] = 'On-link') and (ar1[3] <> '127.0.0.1') then begin
          writeln(ar1[3]);
        end;      end;  end;  end;
  exitcode:= 0;
  application.terminated:= true;
end;

end.
----------------------
Where am me wrong :

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to