soft5257 2015-05-04 03:55 采纳率: 0%
浏览 1701

如何用C#调用这个C++dll的函数

extern "C" PB_RESULT __declspec(dllexport)CRDR_ReadData(OUT char* lpBuffer, IN DWORD dwBufferSize,
OUT DWORD lpNumberOfBytesRead)
{
WriteLog4("[CRDR_ReadData]dwBufferSize=%d",dwBufferSize);
if (m_crdr.m_ptrarrayCardInfo.GetSize()>0)
{
CARD_INFO *pCardInfo = NULL;
pCardInfo = (CARD_INFO
)m_crdr.m_ptrarrayCardInfo.GetAt(0);
int nLenth = strlen(pCardInfo->cardno)+1;
//DWORD dLen = nLenth + 1;
memcpy(lpBuffer,pCardInfo->cardno,nLenth);
*lpNumberOfBytesRead = nLenth-1;
if (pCardInfo != NULL)
delete pCardInfo;
m_crdr.m_ptrarrayCardInfo.RemoveAt(0);
WriteLog4("[CRDR_ReadData]lpBuffer=%s,nLenth=%d",lpBuffer,*lpNumberOfBytesRead);
}

return PB_OK;
}

  • 写回答

4条回答 默认 最新

  • zzkjliu 2015-05-04 04:18
    关注

    P/Invoke C++ Interop

    评论

报告相同问题?