问题描述
- C#调用顶尖PBUSDRV.DLL时,如果保质期shleftime大于3时,下传就报错
-
结构体声明如下:[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TPlu
{
//[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 36)]
public string Name;
public int LFCode;
//[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 10)]
public string code;
public int barcode;public int unitprice; public int weightunit; public int deptment; public double tare; public int shleftime; public int packagetype; public int packageweight; public int tolerance; //[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public byte message1; //[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public byte reserved; public short reserved1; //[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public byte message2; public byte reserved2; //[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public byte multilabel; //[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public byte rebate; public int account; }
其它INT型的参数都一切正常,唯独shleftime大于3时,下传就报错。0-3下传正常。是否要特殊处理?
文档对于保存期shleftime的说明:宽度 3,默认 15,描述:0~365, 其中 364: 不打印有效期; 365: 有效期和包
装日期均不打印包装日期为零时,包装日期及保鲜日
期均打印。然而同样写的PB,VB程序则正常。
解决方案
贴出你所谓正常的VB代码,我可以帮你看看。
时间: 2024-10-25 06:44:01