日期:2014-05-17  浏览次数:20852 次

c# 调用 c++ 的DLL 问题
本帖最后由 Soja 于 2013-12-23 11:57:47 编辑
c++结构:
typedef struct _GLYDEPOSITCOUNTER {
unsigned int EventNumber;
struct tm Time;
unsigned int dwSquentialNo;
unsigned int dwUserID;
GLYCOUNTERS DepositData;
} GLYDEPOSITCOUNTER, *LPGLYDEPOSITCOUNTER;

struct tm Time:
Each data range is as described below.
tm_year: 2000 to 2099, tm_mon: 1 to 12, tm_mday: 1 to 31,
tm_hour: 0 to 23, tm_min: 00 to 59, tm_sec: 00 to 59

typedef struct _GLYCOUNTERS {
    unsigned int ulArraySize;
    LPGLYCOUNTER lpCounters;
} GLYCOUNTERS, *LPGLYCOUNTERS;

typedef struct _GLYCOUNTER {
    unsigned int    dwID;
    unsigned int    dwStatus;
    GLYDENOMINATION Denomination;
    void* misc;
} GLYCOUNTER, *LPGLYCOUNTER;

typedef struct _GLYDENOMINATION {
    unsigned int  ulArraySize;
    LPGLYCURRENCY lpCurrencies;
} GLYDENOMINATION, *LPGLYDENOMINATION;

typedef struct _GLYCURRENCY {
    unsigned int ulValue;
    unsigned int ulCounts;
    char         cCurrencyID[4];
    int          Rev;
    GLYVALUEEXP  ValueExp;
    int          Category;
    GLYSIGNATURE** ppSignature;
    void* misc;
} GLYCURRENCY, *LPGLYCURRENCY;

typedef struct _GLYVALUEEXP {
    int Factor;
    int Exp;
} GLYVALUEEXP, *LPGLYVALUEEXP;

typedef struct _GLYSIGNATURE {
    char* SerialNumber;
    char* SerialNumberAttrib;
    int   DataSize;
    unsigned char* Data;
    void* misc;
} GLYSIGNATURE, *LPGLYSIGNATURE;

我的c#转换是:

    [StructLayout(LayoutKind.Sequential)]
    public struct GlyDepositCounter
    {
        public uint EventNumber;
        public Tm Time;
        public uint dwSquentialNo;
        public uint dwUserID;
        public GlyCounters DepositData;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct Tm
    {
        public int tm_year;
        public int tm_mon;