110,536
社区成员
发帖
与我相关
我的任务
分享
//c++函数强制声明
[DllImport("mi.dll", EntryPoint = "API_OpenComm")]
public static extern IntPtr API_OpenComm(int nCom, int nBaudrate);
[DllImport("mi.dll", EntryPoint = "API_CloseComm")]
public static extern bool API_CloseComm(IntPtr commHandle);
[DllImport("mi.dll", EntryPoint = "API_ControlBuzzer")]
public static extern int API_ControlBuzzer(IntPtr commHandle, int DeviceAddress, byte freq, byte duration, ref byte buffer);
[DllImport("mi.dll", EntryPoint = "API_MF_Read")]
public static extern int API_MF_Read(IntPtr commHandle, int DeviceAddress, byte mode, byte blk_add, byte num_blk, ref byte snr, ref byte buffer);
private void Form1_Load(object sender, EventArgs e)
{
Program.Port = API_OpenComm(4, 9600);
if (Program.Port.ToInt32() == 0)
{
labelControl2.Visible = false;
labelControl3.Visible = true;
buttonX1.Visible = true;
return;
}
byte pBuf = new byte();
Program.G_start = API_ControlBuzzer(Program.Port, 0, 3, 1, ref pBuf);
if (Program.G_start == 0)
{
labelControl2.Visible = true;
labelControl3.Visible = false;
buttonX1.Visible = false;
}
//启动时间轴
timer1.Interval = 1000;
timer1.Start();
}