Ping

cs_klachinkof Messages postés 23 Date d'inscription vendredi 10 décembre 2010 Statut Membre Dernière intervention 3 juin 2012 - 27 avril 2012 à 02:30
cs_L0ci Messages postés 224 Date d'inscription vendredi 26 novembre 2010 Statut Membre Dernière intervention 11 juin 2013 - 28 avril 2012 à 11:39
slt, a tout je veux quelqu’un que me donner l'aide pour avoir récupérai les noms du pc a partie du ping ,et merci d'avance .

3 réponses

cs_L0ci Messages postés 224 Date d'inscription vendredi 26 novembre 2010 Statut Membre Dernière intervention 11 juin 2013 7
27 avril 2012 à 09:10
Bonjour,
tu peux essayer cette solution:
System.Net.IPHostEntry ip =
System.Net.Dns.GetHostByAddress('adresse_ip');
string hostname = ip.HostName;

Cependant attention dans le vocabulaire que tu utilises, l'hostname s'obtient a partir d'une adresse ip et non d'un ping.
0
cs_klachinkof Messages postés 23 Date d'inscription vendredi 10 décembre 2010 Statut Membre Dernière intervention 3 juin 2012
28 avril 2012 à 01:46
MERCI LOci,mais voici mon code comment en peut metre votre code dans ce lui si :
private void button3_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
try
{
int aux = ((begin.Text.Length) - (begin.Text.LastIndexOf('.') + 1));

string debutt = (begin.Text.Substring(begin.Text.LastIndexOf('.') + 1, aux));

aux = ((End.Text.Length) - (End.Text.LastIndexOf('.') + 1));

string finn = (End.Text.Substring(End.Text.LastIndexOf('.') + 1, aux));

int debut = Int32.Parse(debutt);
int fin = Int32.Parse(finn);
int index = 0;
Button b;
Button bb;
Label l;
Label NomPc;
Label macLabel;
listView1.Columns[0].Width = 20;
listView1.Columns[1].Width = 150;
listView1.Columns[2].Width = 150;
listView1.Columns[3].Width = 150;

while (debut <= fin)
{
//ThreadPool.QueueUserWorkItem(new WaitHandle();

debutt = debut.ToString();
string mydebut = begin.Text.Substring(0, begin.Text.LastIndexOf('.') + 1);
mydebut += debutt;
debut++;
////////////////////////////////
Ping pingueur = new Ping();
PingReply reply = pingueur.Send(mydebut, 1000);


if (reply.Status == IPStatus.Success)
{
// MessageBox.Show("Ping de " + mydebut + " OK ");
string MAC = CMD.GetMACDepuisIP(mydebut.ToString());
string nompc = CMD.GetNetBIOSName(mydebut.ToString());
// MessageBox.Show(CMD.GetNetBIOSName(mydebut.ToString()));
listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] { new System.Windows.Forms.ListViewItem("") });
//System.Net.IPHostEntry ip = System.Net.Dns.GetHostByAddress ("ip");
//string hostname = ip.HostName;
// Create some controls and embed them in our ListView

// First, a button:
//p= new PictureBox();
// p.BackgroundImage = new Bitmap("pc.png");
b = new Button();
bb = new Button();
bb.BackColor = System.Drawing.Color.Green;
l = new Label();
l.Text = mydebut;
NomPc = new Label();
NomPc.Text = nompc;
macLabel = new Label();
macLabel.Text = MAC;
b.Image = new Bitmap("pc.png");
//b.Font = this.Font;


// Put it in the first column of the fourth row

listView1.AddEmbeddedControl(b, 0, index);
listView1.AddEmbeddedControl(bb, 2, index);
listView1.AddEmbeddedControl(NomPc, 1, index);
listView1.AddEmbeddedControl(l, 3, index);
listView1.AddEmbeddedControl(macLabel, 4, index);

index++;
}


}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}

}

public string NomPC
{
get { return NomPC; }
0
cs_L0ci Messages postés 224 Date d'inscription vendredi 26 novembre 2010 Statut Membre Dernière intervention 11 juin 2013 7
28 avril 2012 à 11:39
Bonjour,
Je pense que le code peut etre placé ici:
if (reply.Status == IPStatus.Success) 
{ 
System.Net.IPHostEntry ip = System.Net.Dns.GetHostByAddress(mydebut);
string hostname = ip.HostName;
// MessageBox.Show("Ping de " + mydebut + " OK "); 
string MAC = CMD.GetMACDepuisIP(mydebut.ToString()); 
[...]

A voir si la variable mydébut passe bien sinon il suffit de la caster en Uri.
0
Rejoignez-nous