//获得网络邻居所有机器名,方法如下: procedure tform1.button1click(sender: tobject); var command:string; comline: pchar; begin command:='command.com /c net view>c:\~~~.txt'; comline:=pchar(command); winexec(comline, sw_hide); timer1.enabled:=true; end;//每秒试一次 procedure tform1.timer1timer(sender: tobject); var f:tstringlist; ll,ii:integer; s1,s:string; b:bool; begin f:=tstringlist.create; try f.loadfromfile('c:\~~~.txt'); except end; if f.count>10 then begin memo1.clear; memo1.lines.add(f.text); timer1.enabled:=false; f.free; {去掉多余的行和'\\'} for ll:=memo1.lines.count-1 downto 0 do begin if strpos(pchar(memo1.lines.strings[ll]),'\\')=nil then memo1.lines.delete(ll) else memo1.lines.strings[ll]:=delxxx(memo1.lines.strings[ll]); {自编1个去'\\'的函数} end; timer1.enabled:=false; end; 源程序详见: http://delphi21cn.yeah.net http://personal.hb.cninfo.net/~gbh
procedure tform1.button1click(sender: tobject);
var
command:string;
comline: pchar;
begin
command:='command.com /c net view>c:\~~~.txt';
comline:=pchar(command);
winexec(comline, sw_hide);
timer1.enabled:=true;
end;//每秒试一次
procedure tform1.timer1timer(sender: tobject);
var f:tstringlist;
ll,ii:integer;
s1,s:string;
b:bool;
begin
f:=tstringlist.create;
try
f.loadfromfile('c:\~~~.txt');
except
end;
if f.count>10 then begin
memo1.clear;
memo1.lines.add(f.text);
timer1.enabled:=false;
f.free;
{去掉多余的行和'\\'}
for ll:=memo1.lines.count-1 downto 0 do begin
if strpos(pchar(memo1.lines.strings[ll]),'\\')=nil then
memo1.lines.delete(ll)
else
memo1.lines.strings[ll]:=delxxx(memo1.lines.strings[ll]);
{自编1个去'\\'的函数}
end;
timer1.enabled:=false;
end;
源程序详见:
http://delphi21cn.yeah.net
http://personal.hb.cninfo.net/~gbh