 
			
				12/08/2010, 09:57
			
			
			     |  
      |    |    |    Fecha de Ingreso: agosto-2010  
						Mensajes: 5
					  Antigüedad: 15 años, 2 meses Puntos: 0     |        |  
        como puedo cambiar este codigo a vb.net        este es un codigo que encontre por ahi para ver quienes estan conectados al mismo grupo de red...   
namespace HostNIPAddr 
{   
	public class MOSTRAR : System.Windows.Forms.Form 
	{ 
		internal System.Windows.Forms.Button txtcerrar 
		internal System.Windows.Forms.Button txtmostrar 
		internal System.Windows.Forms.ListView ListaPcIp 
		internal System.Windows.Forms.ColumnHeader NombrePc 
		internal System.Windows.Forms.ColumnHeader DireccionIp 
		internal System.Windows.Forms.StatusBar ESTADO; 
		private System.Windows.Forms.TextBox TxtGrupoTrabajo 
		private System.Windows.Forms.Label txtlabel1 
		private System.Windows.Forms.ColumnHeader DireccionMac   
		[DllImport("iphlpapi.dll", ExactSpelling=true)] 
		public static extern int SendARP( int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen )     
		/// <summary> 
		/// Required designer variable. 
		/// </summary> 
		private System.ComponentModel.Container components = null;   
            Public MOSTRAR() 
		{ 
			// 
			// Required for Windows Form Designer support 
			// 
			InitializeComponent();   
			// 
			// TODO: Add any constructor code after InitializeComponent call 
			// 
		}     
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if (components != null)  
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		}   
		#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 void InitializeComponent() 
		{ 
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typ  eof(MOSTRAR)); 
            this.txtcerrar = new System.Windows.Forms.Button(); 
            this.txtmostrar = new System.Windows.Forms.Button(); 
            this.ListaPcIp = new System.Windows.Forms.ListView(); 
            this.NombrePc = new System.Windows.Forms.ColumnHeader(); 
            this.DireccionIp = new System.Windows.Forms.ColumnHeader(); 
            this.DireccionMac = new System.Windows.Forms.ColumnHeader(); 
            this.ESTADO = new System.Windows.Forms.StatusBar(); 
            this.TxtGrupoTrabajo = new System.Windows.Forms.TextBox(); 
            this.txtlabel1 = new System.Windows.Forms.Label(); 
            this.SuspendLayout(); 
            //  
            // txtcerrar 
            //  
            this.txtcerrar.Location = new System.Drawing.Point(361, 203); 
            this.txtcerrar.Name = "txtcerrar"; 
            this.txtcerrar.Size = new System.Drawing.Size(84, 20); 
            this.txtcerrar.TabIndex = 7; 
            this.txtcerrar.Text = "Cerrar"; 
            this.txtcerrar.Click += new System.EventHandler(this.ButClose_Click); 
            //  
            // txtmostrar 
            //  
            this.txtmostrar.Location = new System.Drawing.Point(361, 183); 
            this.txtmostrar.Name = "txtmostrar"; 
            this.txtmostrar.Size = new System.Drawing.Size(84, 20); 
            this.txtmostrar.TabIndex = 6; 
            this.txtmostrar.Text = "Mostrar"; 
            this.txtmostrar.Click += new System.EventHandler(this.ButDisplay_Click); 
            //  
            // ListaPcIp 
            //  
            this.ListaPcIp.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 
            this.NombrePc, 
            this.DireccionIp, 
            this.DireccionMac}); 
            this.ListaPcIp.Location = new System.Drawing.Point(16, 7); 
            this.ListaPcIp.Name = "ListaPcIp"; 
            this.ListaPcIp.Size = new System.Drawing.Size(304, 272); 
            this.ListaPcIp.TabIndex = 5; 
            this.ListaPcIp.UseCompatibleStateImageBehavior = false; 
            this.ListaPcIp.View = System.Windows.Forms.View.Details; 
            //  
            // NombrePc 
            //  
            this.NombrePc.Text = "Nombre Pc"; 
            this.NombrePc.Width = 100; 
            //  
            // DireccionIp 
            //  
            this.DireccionIp.Text = "Direccion IP"; 
            this.DireccionIp.Width = 100; 
            //  
            // DireccionMac 
            //  
            this.DireccionMac.Text = "Direccion Mac"; 
            this.DireccionMac.Width = 125; 
            //  
            // ESTADO 
            //  
            this.ESTADO.Location = new System.Drawing.Point(0, 430); 
            this.ESTADO.Name = "ESTADO"; 
            this.ESTADO.Size = new System.Drawing.Size(484, 32); 
            this.ESTADO.TabIndex = 4; 
            //  
            // TxtGrupoTrabajo 
            //  
            this.TxtGrupoTrabajo.Location = new System.Drawing.Point(361, 111); 
            this.TxtGrupoTrabajo.Name = "TxtGrupoTrabajo"; 
            this.TxtGrupoTrabajo.Size = new System.Drawing.Size(80, 20); 
            this.TxtGrupoTrabajo.TabIndex = 8; 
            this.TxtGrupoTrabajo.Text = "Inacap"; 
            //  
            // txtlabel1 
            //  
            this.txtlabel1.AutoSize = true; 
            this.txtlabel1.Location = new System.Drawing.Point(358, 86); 
            this.txtlabel1.Name = "txtlabel1"; 
            this.txtlabel1.Size = new System.Drawing.Size(92, 13); 
            this.txtlabel1.TabIndex = 9; 
            this.txtlabel1.Text = "Grupo De Trabajo"; 
            //  
            // MOSTRAR 
            //  
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
            this.ClientSize = new System.Drawing.Size(484, 462); 
            this.Controls.Add(this.txtlabel1); 
            this.Controls.Add(this.TxtGrupoTrabajo); 
            this.Controls.Add(this.txtcerrar); 
            this.Controls.Add(this.txtmostrar); 
            this.Controls.Add(this.ListaPcIp); 
            this.Controls.Add(this.ESTADO); 
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.  Icon"))); 
            this.MaximumSize = new System.Drawing.Size(500, 500); 
            this.MinimumSize = new System.Drawing.Size(500, 500); 
            this.Name = "MOSTRAR"; 
            this.Text = "PC CONECTADOS"; 
            this.Load += new System.EventHandler(this.MOSTRAR_Load); 
            this.ResumeLayout(false); 
            this.PerformLayout();   
		} 
		#endregion   
		/// <summary> 
		/// The main entry point for the application. 
		/// </summary> 
		[STAThread] 
		static void Main()  
		{ 
			Application.Run(new MOSTRAR()); 
		}   
		private void ButDisplay_Click(object sender, System.EventArgs e) 
		{ 
			try 
			{   
				this.ESTADO.Text = "Collecting Information...";   
				if(this.TxtGrupoTrabajo.Text.Trim() == "") 
				{ 
					MessageBox.Show("The Work Group name Should Not be Empty"); 
					return; 
				}     
				// Use Your work Group WinNT://&&&&(Work Group Name) 
				DirectoryEntry DomainEntry = new DirectoryEntry("WinNT://" + this.TxtGrupoTrabajo.Text.Trim()); 
				DomainEntry.Children.SchemaFilter.Add("computer");     
				// To Get all the System names And Display with the Ip Address 
				foreach(DirectoryEntry machine in DomainEntry.Children) 
				{ 
					string[] Ipaddr = new string[3]; 
					Ipaddr[0] = machine.Name;   
					System.Net.IPHostEntry Tempaddr = null;   
					try 
					{ 
						Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByName(machine.  Name); 
					} 
					catch(Exception ex) 
					{ 
						MessageBox.Show("Unable to connect woth the system :" + machine.Name ); 
						continue; 
					} 
					System.Net.IPAddress[] TempAd = Tempaddr.AddressList; 
					foreach(IPAddress TempA in TempAd) 
					{ 
						Ipaddr[1] = TempA.ToString();   
						byte[] ab = new byte[6]; 
						int len = ab.Length;   
						// This Function Used to Get The Physical Address 
						int r = SendARP( (int) TempA.Address, 0, ab, ref len ); 
						string mac = BitConverter.ToString( ab, 0, 6 );   
						Ipaddr[2] = mac; 
					}			   
					System.Windows.Forms.ListViewItem TempItem = new ListViewItem(Ipaddr);   
					this.ListaPcIp.Items.Add(TempItem); 
				}   
				this.ESTADO.Text = "CONECTADOS" 
			} 
			catch(Exception ex) 
			{ 
				MessageBox.Show(ex.Message,"Error",System.Windows.  Forms.MessageBoxButtons.OK  ); 
				Application.Exit(); 
			}   
		}   
		private void ButClose_Click(object sender, System.EventArgs e) 
		{ 
			this.Close(); 
		}   
        private void MOSTRAR_Load(object sender, EventArgs e) 
        {   
        } 
	} 
}           |