打印本文 打印本文 关闭窗口 关闭窗口
远程控制篇:获得网络邻居所有机器名
作者:武汉SEO闵涛  文章来源:敏韬网  点击数945  更新时间:2009/4/23 18:42:16  文章录入:mintao  责任编辑:mintao

远程控制篇:获得网络邻居所有机器名

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;

--------------------------------------------
湖北襄樊  官本和(gbh12345@china.com)  2001.4
详见主页源程序:
http://delphi21cn.yeah.net
http://personal.hb.cninfo.net/~gbh

打印本文 打印本文 关闭窗口 关闭窗口