有没有C#大佬帮忙看看这段调用读取身份证信息的代码有没有什么问题,感谢感谢。
[DllImport(dllPath, EntryPoint = "iReadIdentityCard", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int ReadSFZNew(ref int piFingerLen, ref byte[] pucFinger, byte[] pOutInfo);
try
{
int len = 1024;
byte[] szInputParams = new byte[1024];
byte[] newbyte = new byte[102400];
int a = (Int16)ReadSFZNew(ref len, ref szInputParams, newbyte);
MessageBox.Show("a" + a.ToString());
string pCardInfo = System.Text.Encoding.Default.GetString(szInputParams);
pCardInfo = pCardInfo.Replace('\0', ' ').Trim();
string pBusiCardInfo = System.Text.Encoding.Default.GetString(newbyte);
pBusiCardInfo = pBusiCardInfo.Replace('\0', ' ').Trim();
if (a == 0)
{
this.textBox1.Text = pBusiCardInfo;
}
else
{
this.textBox1.Text = a.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
这个是c++头文件的内容:
long __stdcall iReadIdentityCard(int *piFingerLen, unsigned char pucFinger, char pOutInfo);
写法看着没啥问题, pucFinger 是不是还要在封送啥数据过去? 因为参数内容不对所有崩了?
C++头文件的参数类型不对. unsigned char pucFinger, char pOutInfo 这俩参数应该是数组或者指针吧