[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode,Pack=1)]
public struct tagGoodNameUnit
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szGoodsName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string szGoodsUnit;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode,Pack=1)]
public struct tagFpBuyerSellerName
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szFpBuyerName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szFpSellerName;
}
[StructLayout(LayoutKind.Sequential,Pack=1)]
public struct TagGOODSDATA
{
[MarshalAs(UnmanagedType.Struct)]
public tagGoodNameUnit szGoodsNameUnit;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)]
public string szGoodsNum;
}
[StructLayout(LayoutKind.Sequential,Pack=1)]
public struct TagINVOICEEXTDATA
{
[MarshalAs(UnmanagedType.Struct)]
public tagFpBuyerSellerName szFpBuyerSellerName;
//物品行数
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string szGoodsRows;
//物品信息数组
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public TagGOODSDATA[] szGoodsData;
}
[StructLayout(LayoutKind.Sequential)]
public struct TagINVOICEDATA
{
//发票扫描图像文件名
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 258)]
public string szFpImage;
//发票代码(10字节)
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string szFpCode;
//发票印刷序号(8字节)
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string szFpSeriaoNo;
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string szFpCode1;
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string szFpSeriaoNo1;
//加密版本号(2字节)
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string szFpEnVersion;
//开票日期
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string szFpDate;
//税率
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string szFpTaxRate;
//购方纳税号
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string szFpBuyerTaxNo;
//销方纳税号
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string szFpSellerTaxNo;
//价税合计
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
public string szFpTotal;
//金额
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
public string szFpSum;
//税额
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
public string szFpTax;
//密文数据
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string szFpCryptograph;
}
[DllImport("scanreco.dll", ExactSpelling = true)]
public static extern int FpGetNewPage(ref TagINVOICEDATA lpFpBuffer, ref TagINVOICEEXTDATA lpFpExtBuffer, ref int isBarCode);
[DllImport("scanreco.dll", ExactSpelling = true)]
public static extern int FpGetVersion(int nCompanyCode, int nScannerType);
[DllImport("scanreco.dll", ExactSpelling = true)]
public static extern int FpScannerInitialize();
[DllImport("scanreco.dll", ExactSpelling = true)]
public static extern int FpScannerTerminate(int wAction);
TagINVOICEDATA tag = new TagINVOICEDATA();
TagINVOICEEXTDATA tagExt = new TagINVOICEEXTDATA();
int iIsTwoWM = 0;
int iVersion = FpGetVersion(26494179, 51);
int iInitialize = FpScannerInitialize();
int result = FpGetNewPage(ref tag, ref tagExt, ref iIsTwoWM);
int iResult = FpScannerTerminate(0);
this is the c# code,but the struct info is wrong,because of chinese character,i use unicode,but the goods info is wrong