我以代码为例,返回所有局域网内的IP地址procedure GetUserList(fServer:string;List:TStrings);Var NetResource : TNetResource; Buf : Pointer; Count,BufSize,Res : DWord; Ind : Integer; lphEnum : THandle; Temp : PNetResourceArr; s:string;begin //List.Clear; GetMem(Buf, 8192); //申请内存,用于获取工作组信息 try FillChar(NetResource, SizeOf(NetResource), 0); //初始化网络层次信息 NetResource.lpRemoteName := @fServer[1]; //指定工作组名称 NetResource.dwDisplayType := RESOURCEDISPLAYTYPE_SERVER; //类型为服务器(工作组) NetResource.dwUsage := RESOURCEUSAGE_CONTAINER; NetResource.dwScope := RESOURCETYPE_DISK; //列举文件资源信息 Res := WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, RESOURCEUSAGE_CONTAINER, @NetResource,lphEnum); if Res <> 0 then //执行失败 Exit; while True do begin Count := $FFFFFFFF; BufSize := 8192; Res := WNetEnumResource(lphEnum, Count, Pointer(Buf), BufSize); //获取工作组信息 if Res = ERROR_NO_MORE_ITEMS then //资源列举完毕 Exit; if (Res <> 0) then //执行失败 Exit; Temp := PNetResourceArr(Buf); for Ind := 0 to Count - 1 do begin s:= Temp^.lpRemoteName+2; s:= Form1.HostToIP(s); if s <>'' then List.Add(s) ; Inc(Temp); //下一个计算名称 end; end; Res := WNetCloseEnum(lphEnum); //关闭列举 if Res <> 0 Then Raise Exception(Res); finally FreeMem(Buf); end; //forend;如果电脑多的话,速度很慢。