private void btnseardev_Click(object sender, EventArgs e)
{
int ret = 0, i = 0,j = 0,k=0;
byte[] buffer = new byte[64 * 1024];
string str = "";
string[] filed = null;
string[] tmp = null;
string udp = "UDP";
string adr = "255.255.255.255"; MessageBox.Show("Start to SearchDevice!");
this.labsearchdev.Text = "searching ......"; ret = SearchDevice(udp,adr, ref buffer[0]);
if (ret >= 0)
{
int count = this.lsvseardev.Items.Count;
if(count>0)
{
this.lsvseardev.Items.Clear();
}
str = Encoding.Default.GetString(buffer);
str = str.Replace("\r\n", "\t");
tmp = str.Split('\t'); //将多条语句分开 //int p = this.lsvseardev.Items.Count;
while (j < tmp.Length-1)
{
k = 0;
string[] sub_str = tmp[j].Split(','); filed = sub_str[k++].Split('='); //去 “=” 右边的数值赋给列表框里
this.lsvseardev.Items.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); i++; //列表框的下一行
j++; //每一行的下一列
}
this.labsearchdev.Text = "";
this.cmbseardev.Enabled = true;
this.txtnewip.Enabled = true;
this.txtdevpwd.Enabled = true;
this.btnmodip.Enabled = true;
}
else
{
MessageBox.Show("SearchDevice operation is failed!");
return;
}
}
{
int ret = 0, i = 0,j = 0,k=0;
byte[] buffer = new byte[64 * 1024];
string str = "";
string[] filed = null;
string[] tmp = null;
string udp = "UDP";
string adr = "255.255.255.255"; MessageBox.Show("Start to SearchDevice!");
this.labsearchdev.Text = "searching ......"; ret = SearchDevice(udp,adr, ref buffer[0]);
if (ret >= 0)
{
int count = this.lsvseardev.Items.Count;
if(count>0)
{
this.lsvseardev.Items.Clear();
}
str = Encoding.Default.GetString(buffer);
str = str.Replace("\r\n", "\t");
tmp = str.Split('\t'); //将多条语句分开 //int p = this.lsvseardev.Items.Count;
while (j < tmp.Length-1)
{
k = 0;
string[] sub_str = tmp[j].Split(','); filed = sub_str[k++].Split('='); //去 “=” 右边的数值赋给列表框里
this.lsvseardev.Items.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); i++; //列表框的下一行
j++; //每一行的下一列
}
this.labsearchdev.Text = "";
this.cmbseardev.Enabled = true;
this.txtnewip.Enabled = true;
this.txtdevpwd.Enabled = true;
this.btnmodip.Enabled = true;
}
else
{
MessageBox.Show("SearchDevice operation is failed!");
return;
}
}
这个呢
这是Byte数组变量定义
var buffer:array [0..64*1024] of Byte;
int ret = 0, i = 0,j = 0,k=0;
byte[] buffer = new byte[64 * 1024];
string str = "";
string[] filed = null;
string[] tmp = null;
string udp = "UDP";
string adr = "255.255.255.255"; ret = SearchDevice(udp,adr, ref buffer[0]);
if (ret >= 0)
{
str = Encoding.Default.GetString(buffer);
str = str.Replace("\r\n", "\t");
tmp = str.Split('\t'); //将多条语句分开 //int p = this.lsvseardev.Items.Count;
while (j < tmp.Length-1)
{
k = 0;
string[] sub_str = tmp[j].Split(','); filed = sub_str[k++].Split('='); //去 “=” 右边的数值赋给列表框里
this.lsvseardev.Items.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); i++; //列表框的下一行
j++; //每一行的下一列
}
}
int ret = 0, i = 0,j = 0,k=0;
byte[] buffer = new byte[64 * 1024];
string str = "";
string[] filed = null;
string[] tmp = null;
string udp = "UDP";
string adr = "255.255.255.255"; ret = SearchDevice(udp,adr, ref buffer[0]);
if (ret >= 0)
{
str = Encoding.Default.GetString(buffer);
str = str.Replace("\r\n", "\t");
tmp = str.Split('\t'); //将多条语句分开 //int p = this.lsvseardev.Items.Count;
while (j < tmp.Length-1)
{
k = 0;
string[] sub_str = tmp[j].Split(','); filed = sub_str[k++].Split('='); //去 “=” 右边的数值赋给列表框里
this.lsvseardev.Items.Add(filed[1]);
filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); filed = sub_str[k++].Split('=');
this.lsvseardev.Items[i].SubItems.Add(filed[1]); i++; //列表框的下一行
j++; //每一行的下一列
}
}