问题描述
我需要为 atm 创建一个简单的 xfs 驱动程序。我可以毫无问题地调用 WfsStartup 和 WfsOpen,但是当我调用 WfsGetInfo 以获取 WFS_INF_CDM_CASH_UNIT_INFO 时,我没有得到正确的数据。
这是我的方法声明:
[DllImport(@"C:\ProBase\BIN\msxfs.dll")]
public static extern int WFSGetInfo(uint hService,uint dwCategory,byte[] lpQueryDetails,uint dwTimeOut,ref IntPtr wfsInfStatus);
这是我的 CashUnitResult 结构:
public unsafe struct WFSInfCdmCashUnitInfoResult
{
[FieldOffset(0)] public ulong RequestID;
[FieldOffset(2)] public ushort hService;
[FieldOffset(4)] public IntPtr tsTimestamp;
[FieldOffset(6)] public long hResult;
[FieldOffset(8)] public uint dwCommandCode; //dword
[FieldOffset(8)] public uint dwEventID; //dword
[FieldOffset(12)] public IntPtr lpBuffer; //lpvoid
}
lpbuffer 应该指向另一个看起来像这样的结构:
[StructLayout(LayoutKind.Sequential)]
public unsafe struct WFSCdmCuInfo
{
/*[FieldOffset(0)]*/ public ushort usTellerID;
/*[FieldOffset(2)]*/ public ushort usCount;
/*[FieldOffset(4)]*/ public IntPtr lppList; //WFSCdmCashUnitInfo
}
我是这样调用函数的:
int wfsGetInfoResult = XfsManagerCore.WFSGetInfo(lphService,303,null,ref cashUnitInfoResultPtr);
所以当我这样做时:
cashUnitInfoResult = (WFSInfCdmCashUnitInfoResult)Marshal.PtrToStructure(cashUnitInfoResultPtr,typeof(WFSInfCdmCashUnitInfoResult));
我得到了 cashUnitInfoResult 但是当我尝试将结果中的 lpbuffer 解析为:
cdmCuInfo = (WFSCdmCuInfo)Marshal.PtrToStructure(cashUnitInfoResult.lpBuffer,typeof(WFSCdmCuInfo));
应用程序崩溃。我做错了什么??任何帮助将不胜感激。
提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)