Get Barcode data and type from system buffer. BOOL PT_GetBarcodeData
{
UINT * uiBarType, 
Char * pBuffer, 
UINT * uiMaxBufferLen
}
Parameters:
uiBarType [out] barcode type.
pBuffer [out] buffer for storing scanned data.
uiMaxBufferLen [in/out] The max buffer size Return Values Return TRUE if the operation is successful, otherwise return FALSE.Res If the buffer size is less than scan data, function return 0 and the parameter uiMaxBufferLen return the size of barcode data. Example: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"); 
关于PT60扫描枪C++代码,网上查了资料转,有个换成C#代码的版本:[DllImport("scanapiax.dll", EntryPoint = "PT_GetBarcodeData")]
public static extern bool PT_GetBarcodeData(ref uint uiBarType, byte[] pBuffer, ref uint uiMaxBufferLen);
应该是返回扫描枪扫描的数据,不知道怎么用,怎么调用。
ref uint uiBarType, byte[] pBuffer, ref uint uiMaxBufferLen 这参数也看不明白,是如何返回值的。
求各位高手帮忙。

解决方案 »

  1.   

    ref就是引用传递,函数中可以对这个参数进行修改的,这样后续代码可以继续访问新的值
      

  2.   

    自己看啊,C#调用C++dll的参数对应以及转换
    http://blog.csdn.net/sunboyljp/article/details/5110639
      

  3.   

    PT_GetBarcodeData(ref uint uiBarType, byte[] pBuffer, ref uint uiMaxBufferLen);
    该怎么用啊?
      

  4.   

    http://www.cnblogs.com/hwh_/archive/2010/11/16/1878341.html
      

  5.   

                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);
                }