public void get_message()//获取报警消息 { short b = 8; short ret = Fanuc.cnc_rdalmmsg2(Fanuc.h, -1, ref b, msg); string str1 = "msg"; System.Type type = msg.GetType(); if (ret == 0) { for (int i = 1; i < 9; i++) { str1 = "msg" + i; object obj = type.GetField(str1).GetValue(msg); System.Type type1 = obj.GetType(); listBox1.Items.Add("警报数 " + type1.GetField("alm_no").GetValue(obj).ToString() + type1.GetField("alm_msg").GetValue(obj).ToString()); } } else { MessageBox.Show(ret + " "); } }