111,126
社区成员
发帖
与我相关
我的任务
分享
BOOL PT_GetBarcodeData
{
UINT * uiBarType,
Char * pBuffer,
UINT * uiMaxBufferLen
}
if(PT_CheckBarcodeData())
{
if(PT_GetBarcodeData(&uiBarType, pBarData, &uiMaxLen))
{
for(i = 0 ; i < strlen(pBarData) ; i++)
m_strScanData += *(pBarData + i);
}
else m_strScanData = _T("Can't get scan data");
}
else m_strScanData = _T("No Scan Data");
[DllImport("scanapiax.dll", EntryPoint = "PT_GetBarcodeData")]
public static extern bool PT_GetBarcodeData(ref uint uiBarType, byte[] pBuffer, ref uint uiMaxBufferLen);
uint uiBarType = uint.MaxValue;
byte[] buffer = new byte[50];
uint uiMaxBufferLen = (uint)buffer.Length;
bool bSuccess = PT_GetBarcodeData(ref uiBarType, buffer, ref uiMaxBufferLen);
if (bSuccess)
{
Console.Write("成功!条码类型为:{0},扫描数据为:", uiBarType);
foreach (byte ch in buffer)
{
if (ch == 0) //零表示结束
break;
Console.Write(" {0}", ch);
}
}
else
{
Console.Write("失败!需要的缓冲区长度为:{0}字节", uiMaxBufferLen);
}