如何将生物识别设备与SDK连接?

时间:2018-07-22 12:47:57

标签: c# asp.net biometrics

SDK用户手册: https://www.scribd.com/doc/270839166/SBXPC-OCX-Reference-Manual-v3-03

Webform1.cs:

public string ip = "192.168.1.109";
 protected void Button_click(object sender, EventArgs e)
        {
            try
            {

                bool status = sbxpc.SBXPCDLL.ConnectTcpip(1, ip, 5005, 0);
                if (status)
                {

                    bool ss = sbxpc.SBXPCDLL.GetSerialNumber(1, out ip);
                    Button1.Text = "connected";
                    Response.Write("success" + ip);
                }

            }
            catch (Exception ee)
            {
                Response.Write(ee);
            }
        }

sbxpc.SBXPCDLL.cs:

[DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
static extern byte _ConnectTcpip(Int32 dwMachineNumber, ref IntPtr lpszIPAddress, Int32 dwPortNumber, Int32 dwPassWord);
public static bool ConnectTcpip(Int32 dwMachineNumber, string lpszIPAddress, Int32 dwPortNumber, Int32 dwPassWord)
{
    if (lpszIPAddress == null)
        return false;
    IntPtr string_in = Marshal.StringToBSTR(lpszIPAddress);
    try
    {
        byte ret = _ConnectTcpip(dwMachineNumber, ref string_in, dwPortNumber, dwPassWord);
        return ret > 0;
    }
    catch (Exception)
    {
        return false;
    }
    finally
    {
        Marshal.FreeBSTR(string_in);
    }
}

上面的代码仅在某些时候有效,一段时间后第一次与设备连接却没有连接。我不知道为什么会这样。谁能帮我纠正。

0 个答案:

没有答案