东凑西拼弄个类似netstat -an命令的程序,列和列之间蹭得很不对齐,如何对齐后输出呢?分少没办法,新来的,希望不嫌弃!输入代码
dataCount0:=High(datas)+1;
if dataCount0=0 then
begin
Writeln('The command completed successfully.');
end
else
begin
Writeln(
'Proto',#9,
'Local Address',#9,
'Foreign Address',#9,
'State',#9,
'PID',#9,
'ProcessName',#9); for i:=Low(datas) to High(datas) do
begin
Writeln(datas[i].protocol,#9,
datas[i].LocalAddr,#9,
datas[i].RemoteAddr,#9,
datas[i].State,#9,
datas[i].ProcessID,#9,
datas[i].FileName);
end;
Writeln;
Writeln('The command completed successfully.');
运行输出后情况:Proto Local Address Foreign Address State PID ProcessName
TCP 0.0.0.0:21 0.0.0.0:32888 LISTEN 540 Serv-U.exe
UDP 127.0.0.1:2827 *.*.*.*:* 2716 360rp.exe
UDP 192.168.1.150:123 *.*.*.*:* 1148 svchost.exe
UDP 192.168.1.150:137 *.*.*.*:* 4 System
UDP 192.168.1.150:138 *.*.*.*:* 4 System
UDP 192.168.1.150:1900 *.*.*.*:* 1308 svchost.exe
UDP 0.0.0.0:0 *.*.*.*:* 0 [System Process]
dataCount0:=High(datas)+1;
if dataCount0=0 then
begin
Writeln('The command completed successfully.');
end
else
begin
Writeln(
'Proto',#9,
'Local Address',#9,
'Foreign Address',#9,
'State',#9,
'PID',#9,
'ProcessName',#9); for i:=Low(datas) to High(datas) do
begin
Writeln(datas[i].protocol,#9,
datas[i].LocalAddr,#9,
datas[i].RemoteAddr,#9,
datas[i].State,#9,
datas[i].ProcessID,#9,
datas[i].FileName);
end;
Writeln;
Writeln('The command completed successfully.');
运行输出后情况:Proto Local Address Foreign Address State PID ProcessName
TCP 0.0.0.0:21 0.0.0.0:32888 LISTEN 540 Serv-U.exe
UDP 127.0.0.1:2827 *.*.*.*:* 2716 360rp.exe
UDP 192.168.1.150:123 *.*.*.*:* 1148 svchost.exe
UDP 192.168.1.150:137 *.*.*.*:* 4 System
UDP 192.168.1.150:138 *.*.*.*:* 4 System
UDP 192.168.1.150:1900 *.*.*.*:* 1308 svchost.exe
UDP 0.0.0.0:0 *.*.*.*:* 0 [System Process]
TCP 192.168.1.150:808 222.186.27.9:1980 等待时间 0
TCP 192.168.1.150:3377 66.102.7.167:80 等待关闭 3844
TCP 192.168.1.150:3378 66.102.7.167:80 等待关闭 3844
UDP 0.0.0.0:2838 *.*.*.*:* 3884
UDP 0.0.0.0:3600 *.*.*.*:* 1820
UDP 0.0.0.0:4000 *.*.*.*:* 3408
UDP 0.0.0.0:13355 *.*.*.*:* 3408
UDP 127.0.0.1:123 *.*.*.*:* 1148
UDP 127.0.0.1:1030 *.*.*.*:* 1820