Click here to Skip to main content
15,902,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
typedef struct tagGOODSDATA {
       wchar_t        szGoodsName [128];        //1.物品名称
       wchar_t        szGoodsUnit [32];         //2.物品单位
       char           szGoodsNum[24];           //3.物品数量
}GOODSDATA, *PGOODSDATA;

C#
typedef struct tagINVOICEEXTDATA {
       wchar_t         szFpBuyerName[128];          //1.购方企业名称
       wchar_t         szFpSellerName[128];         //2.销方企业名称
       char            szGoodsRows[4];                      //3.物品行数
       GOODSDATA       szGoodsData[8];              //4.物品信息数组
}INVOICEEXTDATA, *PINVOICEEXTDATA;


C#
typedef struct tagINVOICEDATA {
    char    szFpImage[258];             //  发票扫描图像文件名
    char    szFpCode[20];               //1:发票代码(10字节)
    char    szFpSeriaoNo[20];           //3:发票印刷序号(8字节)
    char    szFpCode1[20];
    char    szFpSeriaoNo1[20];          //3:发票印刷序号(8字节)
    char    szFpEnVersion[10];          //  加密版本号(2字节) ???
    char    szFpDate[20];               //2:发票开票日期(6字节)
    char    szFpTaxRate[10];            //8:税率 !!!
    char    szFpBuyerTaxNo[30];         //4:购方纳税号(15/17/18/20字节)
    char    szFpSellerTaxNo[30];        //7:销方纳税号(15/17/20字节)
    char    szFpTotal[40];              //  价税合计
    char    szFpSum[40];                //5:金额
    char    szFpTax[40];                //6:税额 !!!
    char    szFpCryptograph[1024];      //0:密文数据(84/108/780字节)
}INVOICEDATA, *PINVOICEDATA;

int WINAPI FpGetVersion(int nCompanyCode, int nScannerType);
int WINAPI FpScannerInitialize(void);
int WINAPI FpScannerTerminate(int wAction);
int WINAPI FpGetNewPage(PINVOICEDATA lpFpBuffer, PINVOICEEXTDATA lpFpExtBuffer, int *isBarCode);
Posted
Comments
Sandeep Mewara 27-Apr-12 5:50am    
Not clear.

The keyword here is DllImport
Check this out - http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx[^]
 
Share this answer
 
C#
[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;
        }

C#
[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;
        }

C#
[StructLayout(LayoutKind.Sequential,Pack=1)]
        public struct TagGOODSDATA
        {
            [MarshalAs(UnmanagedType.Struct)]
            public tagGoodNameUnit szGoodsNameUnit;
            //物品数量
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)]
            public string szGoodsNum;
        }

SQL
[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;
        }

VB
[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;
        }

C#
[DllImport("scanreco.dll", ExactSpelling = true)]
        public static extern int FpGetNewPage(ref TagINVOICEDATA lpFpBuffer, ref TagINVOICEEXTDATA lpFpExtBuffer, ref int isBarCode);

C#
[DllImport("scanreco.dll", ExactSpelling = true)]
        public static extern int FpGetVersion(int nCompanyCode, int nScannerType);

C#
[DllImport("scanreco.dll", ExactSpelling = true)]
        public static extern int FpScannerInitialize();

C#
[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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900