Get a list of the network connecteds units  

Send By: Arturo Garcia
Web : N.A.
Email: sArthur7@teleline.es
Date: 15/07/00

Tip accessed 459 times

 


  • Add a TListBox (ListBox1) in your form
  • Put this code into the OnClick event of any TButton:


     procedure TForm1.Button1Click(Sender: TObject);
    
       Function GetNetworkDriveMappings(SList:TStrings):Integer;
       Var
        I:Char;
        ThePath:String;
        MaxNetPathLen:DWord;
       Begin
         SList.Clear;
         MaxNetPathLen:=MAX_PATH;
         SetLength(ThePath,MAX_PATH);
    
         For I := 'A' to 'Z' Do
          if WNetGetConnection(PChar(''+I+':'),PChar(ThePath),
                               MaxNetPathLen)<>ERROR_NOT_CONNECTED then
          SList.Add(I+': '+ThePath);
    
          {Devuelve el numero de conexiones}
          Result := SList.Count;
       End;
     begin
       GetNetworkDriveMappings(Listbox1.items);
     end;