C++转换C#后如何使用

qilinzd 2012-03-28 10:13:32
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.

Remarks 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 这参数也看不明白,是如何返回值的。
求各位高手帮忙。
...全文
181 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
EnForGrass 2012-03-28
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
Get Barcode data and type from system buffer.
C/C++ code

BOOL PT_GetBarcodeData
{
UINT * uiBarType,
Char * pBuffer,
UINT * uiMaxBufferLen
}



Parameters:
uiBarType [out] barcode type.
pBuff……
[/Quote]
自己看啊,C#调用C++dll的参数对应以及转换
http://blog.csdn.net/sunboyljp/article/details/5110639
bdmh 2012-03-28
  • 打赏
  • 举报
回复
ref就是引用传递,函数中可以对这个参数进行修改的,这样后续代码可以继续访问新的值
WAN 2012-03-28
  • 打赏
  • 举报
回复
            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);
}
CqCoder 2012-03-28
  • 打赏
  • 举报
回复
http://www.cnblogs.com/hwh_/archive/2010/11/16/1878341.html
qilinzd 2012-03-28
  • 打赏
  • 举报
回复
PT_GetBarcodeData(ref uint uiBarType, byte[] pBuffer, ref uint uiMaxBufferLen);
该怎么用啊?

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧