Jump to content
Fórum Script Brasil
  • 0

Saber Todos Todos Os Hosts Da Rede


Mayron Cachina

Question

1 answer to this question

Recommended Posts

  • 0

Vai ma dica: PROCURAR COMPUTADORES DA REDE

procedure FindComputers(Workgroup: string; aResList: TStrings);
var
  eNumHandle : THandle;
  WorkgroupRS : TNetResource;
  Buf : array[1..500] of TNetResource;
  BufSize : DWORD;
  Entries : DWORD;
  Result : integer;
  sComputer: String;
 begin

  if not Assigned(aResList) then
    Exit;

  aResList.Clear;
  WorkGroup := Workgroup + #0;
  FillChar(WorkGroupRS, SizeOf(WorkGroupRS), 0);

  with WorkgroupRS do begin
    dwScope := 2;
    dwType := 3;
    dwDisplayType := 1;
    dwUsage := 1;
    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
    sComputer:= StrPas(Buf[1].lpRemoteName);
    aResList.Add(Copy(sComputer, 3, Length(sComputer)-2));
  end;

 until (Entries <> 1) or (Result <> NO_Error);

  WNetCloseENum(ENumHandle);

 end;

Edited by Jhonas
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.6k
×
×
  • Create New...