注意:代码仅供参考,需要根据具体的设备做调整
同系列文章:
演示程序源代码下载:
FaceIdDemo-CS-20161118.zip
注意:请将FaceId.dll加入工程引用
演示程序界面:
/* ---------------------------------------------------------- * 文件名称:Form1.cs * 作者:秦建辉 * * QQ:36748897 * * 博客:http://www.firstsolver.com/wordpress/ * * 开发环境: * Visual Studio V2013 * .NET Framework 4.0 * * 版本历史: * V1.0 2014年09月12日 * 人脸通SDK演示:执行设备命令 ------------------------------------------------------------ */ using System; using System.Linq; using System.Windows.Forms; namespace Splash { public partial class Form1 : Form { /// <summary> /// 设备通信字符集为简体中文 /// </summary> private const Int32 DeviceCodePage = 936; public Form1() { InitializeComponent(); } private void buttonClear_Click(object sender, EventArgs e) { textBoxAnswer.Clear(); } private void buttonExecuteCommand_Click(object sender, EventArgs e) { try { using(FaceId Client = new FaceId(textBoxDeviceIP.Text, Convert.ToInt32(textBoxDevicePort.Text))) { String Answer; FaceId_ErrorCode ErrorCode = Client.Execute(textBoxDeviceCommand.Text, out Answer, DeviceCodePage); if(ErrorCode == FaceId_ErrorCode.Success) { textBoxAnswer.Text = Answer; } else { MessageBox.Show("错误代码:" + ErrorCode.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch(Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }