salve a tutti,
ho questo codice che mi restituisce una list contenente tutti i computer in una rete aziendale e dice se è spento o no:
ora però io vorrei inserire il nome del pc prima di richiamare la funzione PingPC e solo se la funzione restituisce false scrivere spento nell'elemento appena aggiunto... è possibile fare ciò?codice:Function PingPC(ByVal NomePC As String) As Boolean Try Return My.Computer.Network.Ping(NomePC) Catch ex As System.Net.NetworkInformation.PingException Return False End Try End Function Function VerificaPC() As List(Of String) Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://nomedominio") Dim mySearcher As DirectorySearcher = New DirectorySearcher(entry) Dim NomePC As String, lstPC As List(Of String) = Nothing, intPC As Integer mySearcher.Filter = ("(objectClass=computer)") lstPC = New List(Of String) For Each resEnt As SearchResult In mySearcher.FindAll() NomePC = resEnt.GetDirectoryEntry().Name.Replace("CN=", "") Select Case PingPC(NomePC) Case False lstPC(intPC) = NomePC & " (Spento)" Case True lstPC.Add(NomePC) End Select Application.DoEvents() Next lstPC.Sort() Return lstPC End Function