Foros del Web » Programación para mayores de 30 ;) » .NET »

problema con codigo en vb.net

Estas en el tema de problema con codigo en vb.net en el foro de .NET en Foros del Web. lo que pasa es que baje este codigo que me muestra a todas las personas conectadas a la misma red, pero yo lo necesito que ...
  #1 (permalink)  
Antiguo 12/08/2010, 19:08
 
Fecha de Ingreso: agosto-2010
Mensajes: 5
Antigüedad: 14 años, 3 meses
Puntos: 0
Pregunta problema con codigo en vb.net

lo que pasa es que baje este codigo que me muestra a todas las personas conectadas a la misma red, pero yo lo necesito que sea wifi ojala me puedan ayudar

le escribo el codigo:

Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Net
Imports System.DirectoryServices
Imports System.Runtime.InteropServices


Namespace HostNIPAddr
''' <summary>
''' Summary description for Form1.
''' </summary>
Public Class Form1
Inherits System.Windows.Forms.Form
Friend ButClose As System.Windows.Forms.Button
Friend ButDisplay As System.Windows.Forms.Button
Friend ListHostIP As System.Windows.Forms.ListView
Friend HostName As System.Windows.Forms.ColumnHeader
Friend IpAddr As System.Windows.Forms.ColumnHeader
Friend Status As System.Windows.Forms.StatusBar
Private TxtWorkGroup As System.Windows.Forms.TextBox
Private label1 As System.Windows.Forms.Label
Private PhyAdd As System.Windows.Forms.ColumnHeader

<DllImport("iphlpapi.dll", ExactSpelling := True)> _
Public Shared Function SendARP(DestIP As Integer, SrcIP As Integer, <Out> pMacAddr As Byte(), ByRef PhyAddrLen As Integer) As Integer
End Function


''' <summary>
''' Required designer variable.
''' </summary>
Private components As System.ComponentModel.Container = Nothing

Public Sub New()
'
' Required for Windows Form Designer support
'

'
' TODO: Add any constructor code after InitializeComponent call
'
InitializeComponent()
End Sub

''' <summary>
''' Clean up any resources being used.
''' </summary>
Protected Overrides Sub Dispose(disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Dim resources As New System.Resources.ResourceManager(GetType(Form1))
Me.ButClose = New System.Windows.Forms.Button()
Me.ButDisplay = New System.Windows.Forms.Button()
Me.ListHostIP = New System.Windows.Forms.ListView()
Me.HostName = New System.Windows.Forms.ColumnHeader()
Me.IpAddr = New System.Windows.Forms.ColumnHeader()
Me.PhyAdd = New System.Windows.Forms.ColumnHeader()
Me.Status = New System.Windows.Forms.StatusBar()
Me.TxtWorkGroup = New System.Windows.Forms.TextBox()
Me.label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
' ButClose
'
Me.ButClose.Location = New System.Drawing.Point(380, 272)
Me.ButClose.Name = "ButClose"
Me.ButClose.Size = New System.Drawing.Size(84, 20)
Me.ButClose.TabIndex = 7
Me.ButClose.Text = "Close"
AddHandler Me.ButClose.Click, New System.EventHandler(AddressOf Me.ButClose_Click)
'
' ButDisplay
'
Me.ButDisplay.Location = New System.Drawing.Point(380, 252)
Me.ButDisplay.Name = "ButDisplay"
Me.ButDisplay.Size = New System.Drawing.Size(84, 20)
Me.ButDisplay.TabIndex = 6
Me.ButDisplay.Text = "Display"
AddHandler Me.ButDisplay.Click, New System.EventHandler(AddressOf Me.ButDisplay_Click)
'
' ListHostIP
'
Me.ListHostIP.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.HostName, Me.IpAddr, Me.PhyAdd})
Me.ListHostIP.Location = New System.Drawing.Point(40, 16)
Me.ListHostIP.Name = "ListHostIP"
Me.ListHostIP.Size = New System.Drawing.Size(304, 272)
Me.ListHostIP.TabIndex = 5
Me.ListHostIP.View = System.Windows.Forms.View.Details
'
' HostName
'
Me.HostName.Text = "Host Name"
Me.HostName.Width = 100
'
' IpAddr
'
Me.IpAddr.Text = "IP Address"
Me.IpAddr.Width = 100
'
' PhyAdd
'
Me.PhyAdd.Text = "Physical Address"
Me.PhyAdd.Width = 125
'
' Status
'
Me.Status.Location = New System.Drawing.Point(0, 303)
Me.Status.Name = "Status"
Me.Status.Size = New System.Drawing.Size(472, 22)
Me.Status.TabIndex = 4
'
' TxtWorkGroup
'
Me.TxtWorkGroup.Location = New System.Drawing.Point(352, 80)
Me.TxtWorkGroup.Name = "TxtWorkGroup"
Me.TxtWorkGroup.Size = New System.Drawing.Size(80, 20)
Me.TxtWorkGroup.TabIndex = 8
Me.TxtWorkGroup.Text = "Baba"
'
' label1
'
Me.label1.AutoSize = True
Me.label1.Location = New System.Drawing.Point(356, 56)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(98, 16)
Me.label1.TabIndex = 9
Me.label1.Text = "Work Group Name"
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(472, 325)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.TxtWorkGroup)
Me.Controls.Add(Me.ButClose)
Me.Controls.Add(Me.ButDisplay)
Me.Controls.Add(Me.ListHostIP)
Me.Controls.Add(Me.Status)
Me.Icon = DirectCast(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MaximumSize = New System.Drawing.Size(480, 352)
Me.MinimumSize = New System.Drawing.Size(480, 352)
Me.Name = "Form1"
Me.Text = "System Info"
Me.ResumeLayout(False)

End Sub
#End Region

''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Private Shared Sub Main()
Application.Run(New Form1())
End Sub

Private Sub ButDisplay_Click(sender As Object, e As System.EventArgs)
Try

Me.Status.Text = "Collecting Information..."

If Me.TxtWorkGroup.Text.Trim() = "" Then
MessageBox.Show("The Work Group name Should Not be Empty")
Return
End If


' Use Your work Group WinNT://&&&&(Work Group Name)
Dim DomainEntry As New DirectoryEntry("WinNT://" & Me.TxtWorkGroup.Text.Trim())
DomainEntry.Children.SchemaFilter.Add("computer")


' To Get all the System names And Display with the Ip Address
For Each machine As DirectoryEntry In DomainEntry.Children
Dim Ipaddr As String() = New String(2) {}
Ipaddr(0) = machine.Name

Dim Tempaddr As System.Net.IPHostEntry = Nothing

Try
Tempaddr = DirectCast(Dns.GetHostByName(machine.Name), System.Net.IPHostEntry)
Catch ex As Exception
MessageBox.Show("Unable to connect woth the system :" + machine.Name)
Continue Try
End Try
Dim TempAd As System.Net.IPAddress() = Tempaddr.AddressList
For Each TempA As IPAddress In TempAd
Ipaddr(1) = TempA.ToString()

Dim ab As Byte() = New Byte(5) {}
Dim len As Integer = ab.Length

' This Function Used to Get The Physical Address
Dim r As Integer = SendARP(CInt(TempA.Address), 0, ab, len)
Dim mac As String = BitConverter.ToString(ab, 0, 6)

Ipaddr(2) = mac
Next

Dim TempItem As System.Windows.Forms.ListViewItem = New ListViewItem(Ipaddr)

Me.ListHostIP.Items.Add(TempItem)
Next

Me.Status.Text = "Displayed"
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK)
Application.[Exit]()
End Try

End Sub

Private Sub ButClose_Click(sender As Object, e As System.EventArgs)
Me.Close()
End Sub
End Class
End Namespace

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:54.