コード例 #1
0
        //定时器 定时查看设备连接状态
        private void timerCheck_Tick(object sender, EventArgs e)
        {
            if (!deviceState)
            {
                int flag = Dll_Camera.StartDevice();

                //Dll_Camera.StartDevice();启动设备
                //int result = Dll_Camera.GetDevice();

                if (flag == 1)
                //if(result == 1)
                {
                    //第三步:设置打开蜂鸣器,DLL默认不打开
                    Dll_Camera.SetBeep(true);
                    //设置一维
                    Dll_Camera.setBarcode(barEnable);
                    //设置qr
                    Dll_Camera.setQRable(qrEnable);
                    //设置dm
                    Dll_Camera.setDMable(dmEnable);
                    //设置扫码成功蜂鸣
                    Dll_Camera.SetBeepTime(100);
                    Dll_Camera.SetDecodeTime(200);

                    deviceState         = true;
                    this.labelText.Text = "解码信息:(设备已连接)";
                }
                else if (flag == -1)
                {
                    this.labelText.Text = "解码信息:(设备已启动)";
                }
                else if (flag == -2)
                {
                    this.labelText.Text = "解码信息:(设备已断开)";
                }
                else if (flag == -3)
                {
                    this.labelText.Text = "解码信息:(设备已初始化失败)";
                }
            }
            else
            {
                int result = Dll_Camera.GetDevice();
                // 定时获取设备信息
                if (result == 1)
                {
                    this.labelText.Text = "解码信息:(设备已连接)";
                }
                else
                {
                    deviceState = false;
                    Dll_Camera.ReleaseLostDevice();
                    this.labelText.Text = "解码信息:(设备已断开)";
                }
            }
        }
コード例 #2
0
 private void TestForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (deviceState == true)
     {
         Dll_Camera.ReleaseDevice();
     }
     else
     {
         Dll_Camera.ReleaseLostDevice();
     }
 }