Fórum Computadores da Rede #207469
19/01/2004
0
Fabioavallone
Curtir tópico
+ 0Posts
20/01/2004
Anisio
por favor, alguém responda a nossa dúvida :D
Gostei + 0
20/01/2004
Anisio
to precisando ta rotina...naum encontro em lugar nenhum
Gostei + 0
21/01/2004
Anisio
Ta aí Fabio, espero q funcione no XP (no 98 funciona)
soh coloque um TreeView no form
procedure TUserNet.GetNetwork(it:TTreeNode; lpNetResource:PNetResourceA);
type
PNetResourceArray = ^TNetResourceArray;
TNetResourceArray = array[0..MaxInt div SizeOf(TNetResource) - 1] of TNetResource;
var neh,cnt,size:cardinal;
netres:integer;
res:PNetResourceArray;
i:integer;
s:string;
itc:TTreeNode;
begin
{ Inicializando Variáveis }
cnt := $FFFFFFFF;
Size := 50 * SizeOf(TNetResource);
{ Abre a enumeração }
if WNetOpenEnum(RESOURCE_CONTEXT, RESOURCETYPE_DISK, 0, lpNetResource, neh) = NO_ERROR then
try
{ Alocando Memória }
GetMem(Res, Size);
{ Buscar os recursos da net }
netres := WNetEnumResource(neh, cnt, res, size);
{ Se houver erro }
if netres = NO_ERROR then
begin
{ If not browse through the fetxhed net resources }
for i := 0 to cnt - 1 do
{ Controlling if usage is not a network share }
if not (res^[i].dwUsage in [1,5]) then
begin
{ Since the name includes full path we have to cut the path off }
s := copy(res^[i].lpRemoteName, lastdelimiter(´´, res^[i].lpRemoteName) + 1,
length(res^[i].lpRemoteName));
{ If we are in the root }
if lpnetresource = nil then
{ Set the TreeNode to the root. This skips the ´Microsoft Windows Network´
node and goes directly to the list of workgroups and domains }
itc := it
else
{ Add a child to the selected TreeNode }
itc := trvNetwork.Items.AddChild(it, s);
{ Call the procedure for the actual net resource }
GetNetwork(itc, @res^[i]);
end;
end;
finally
{ Freeing memory }
FreeMem(Res, Size);
end;
{ Closing the enumeration }
WNetCloseEnum(neh);
end;
{ Filling the TreeView when creating the form }
procedure TUserNet.FormCreate(Sender: TObject);
begin
GetNetwork(nil,nil);
TrVnetwork.FullExpand;
TrVnetwork.Selected := TrVnetwork.Items[0];
end;Gostei + 0
05/07/2015
Eraldo Bezerra
{ Add a child to the selected TreeNode }
itc := trvNetwork.Items.AddChild(it, s);
que ha?
Gostei + 0
05/07/2015
Rodrigo Oliveira
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)