如何把网上邻居加入到combobox的列表中?

sbxtzhl 2003-02-15 05:42:19
谢谢
...全文
67 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
307 2003-02-15
  • 打赏
  • 举报
回复
同意Drate(鸟窝里的虫),我试过,再处理一下就可以
procedure TForm1.Button1Click(Sender: TObject);
begin
winexec('cmd /c net view>c:\ttt.txt',sw_hide);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
combobox1.Items.LoadFromFile('c:\ttt.txt');
end;
grail_ 2003-02-15
  • 打赏
  • 举报
回复

var

Computer : Array[1..500] of String[25];

ComputerCount : Integer;





procedure FindAllComputers(Workgroup : String);

Var

EnumHandle : THandle;

WorkgroupRS : TNetResource;

Buf : Array[1..500] of TNetResource;

BufSize : Integer;

Entries : Integer;

Result : Integer;



begin

ComputerCount := 0;



Workgroup := Workgroup + #0;



FillChar(WorkgroupRS, SizeOf(WorkgroupRS) , 0);

With WorkgroupRS do begin

dwScope := 2;

dwType := 3;

dwDisplayType := 1;

dwUsage := 2;

lpRemoteName := @Workgroup[1];

end;



WNetOpenEnum( RESOURCE_GLOBALNET,

RESOURCETYPE_ANY,

0,

@WorkgroupRS,

EnumHandle );



Repeat

Entries := 1;

BufSize := SizeOf(Buf);



Result :=

WNetEnumResource( EnumHandle,

Entries,

@Buf,

BufSize );

If (Result = NO_ERROR) and (Entries = 1) then begin

Inc( ComputerCount );

Computer[ ComputerCount ] := StrPas(Buf[1].lpRemoteName);

end;

Until (Entries <> 1) or (Result <> NO_ERROR);



WNetCloseEnum( EnumHandle );

end; { Find All Computers }


Drate 2003-02-15
  • 打赏
  • 举报
回复
得网上邻居中的所有计算机
//windows 2000
begin
winexec('cmd /c net view>c:\ttt.txt',sw_hide);
end;

//windows 9x
begin
winexec('command.com /c net view>c:\ttt.txt',sw_hide);
end;

然后到c:\ttt.txt看看。剩下的事情就是把c:\ttt.txt中的内容读取到listbox中了

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧