Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class SurroundingClass
- Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
- Dim netUtility As Process = New Process()
- netUtility.StartInfo.FileName = "net.exe"
- netUtility.StartInfo.CreateNoWindow = True
- netUtility.StartInfo.Arguments = "view"
- netUtility.StartInfo.RedirectStandardOutput = True
- netUtility.StartInfo.UseShellExecute = False
- netUtility.StartInfo.RedirectStandardError = True
- netUtility.Start()
- Dim streamReader As StreamReader = New StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding)
- Dim line As String = ""
- While (CSharpImpl.__Assign(line, streamReader.ReadLine())) IsNot Nothing
- If line.StartsWith("\") Then
- Dim pcname As String = line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper()
- Dim myIP As String = Convert.ToString(Dns.GetHostByName(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper()).AddressList(0).ToString())
- Dim item As ListViewItem = New ListViewItem(New String() {pcname, myIP}, 0)
- listView1.Items.AddRange(New ListViewItem() {item})
- End If
- End While
- streamReader.Close()
- netUtility.WaitForExit(1000)
- End Sub
- Private Class CSharpImpl
- <Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
- Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
- target = value
- Return value
- End Function
- End Class
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement