Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#9

Re: ComboBox-Eintraege doppelt und x-fach vorhanden

  Alt 7. Dez 2006, 08:29
Etwa so habe ich es gemeint:

Delphi-Quellcode:
function GetNetComputerNames(const workGroup: String; list: TStrings): Boolean;
var
  I: Integer;
  hEnum: THandle;
  Entries: DWORD;
  BufferSize: DWORD;
  NetResourceBuf: Array[0..511] of TNetResource;
  NetResource: TNetResource;
begin
  list.Clear;
  NetResource.dwScope := RESOURCE_GLOBALNET;
  NetResource.dwType := RESOURCETYPE_ANY;
  NetResource.dwDisplayType := RESOURCEDISPLAYTYPE_GENERIC;
  NetResource.dwUsage := RESOURCEUSAGE_CONNECTABLE;
  NetResource.lpLocalName := nil;
  NetResource.lpRemoteName := PChar(workGroup);
  NetResource.lpComment := nil;
  NetResource.lpProvider := nil;

  Result := WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, @NetResource, hEnum) = NO_ERROR;
  if not Result then Exit;

  Entries := DWORD(-1);
  BufferSize := DWORD(16384);
  while WNetEnumResource(hEnum, Entries, @NetResourceBuf[0], BufferSize) = NO_ERROR do
    for i := 0 to Entries - 1 do
      if not SameText(NetResourceBuf[I].lpRemoteName, '\\' + GetLocalComputerName) then
        list.Add(NetResourceBuf[I].lpRemoteName)
  WNetCloseEnum(hEnum);
end;
Freundliche Grüße
  Mit Zitat antworten Zitat