110,536
社区成员
发帖
与我相关
我的任务
分享
[DllImport("xxxx.dll")]
public extern static int ReadIC(int start, int len, byte[] str);
void button8_Click(object sender, EventArgs e)
{
string s;
int i, j, start, len;
byte[] buff = new byte[64];
s = "";
start = comboBox7.SelectedIndex | (comboBox6.SelectedIndex << 8);
len = Convert.ToInt32(comboBox8.Text);
buff[0] = (byte)comboBox5.SelectedIndex;
for (i = 1; i <= 6; i++)
{
try
{
buff[i] = Convert.ToByte(textBox1.Text.Substring(i * 2 - 2, 2), 16);
}
catch (Exception)
{
Microsoft.VisualBasic.Interaction.Beep(); // 项目中要添加 Microsoft.VisualBasic 引用
MessageBox.Show("数据错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox14.Focus();
return;
}
}
i = ReadIC(start, len, buff);
if (i == 0)
{
for (j = 0; j <= len - 1; j++)
s = s + buff[j].ToString("X2");
}
textBox21.Text = s;
MessageBox.Show("Result: " + i);
}