LEOXI82
LEOXI82
2015-08-11 03:58

关于C#调用C++dll的问题

  • struct
  • c#
  • c++
  • typedef

在c#调用dll中遇到了个巨坑,请大侠&大神帮忙
c++定义:
//! 长度为10的字符串
typedef char TAPISTR_10[11];
typedef char TAPICHAR;
typedef char TAPIDTSTAMP[24];

//! int 32
typedef int TAPIINT32;
//! unsigned 32
typedef unsigned int TAPIUINT32;
//! int 64
typedef long long TAPIINT64;
//! unsigned 64
typedef unsigned long long TAPIUINT64;
//! unsigned 16
typedef unsigned short TAPIUINT16;
//! unsigned 8
typedef unsigned char TAPIUINT8;
//! real 64
typedef double TAPIREAL64;

typedef TAPIREAL64 TAPIQPRICE;
typedef TAPIUINT64 TAPIQVOLUME;
typedef TAPIINT64 TAPIQDIFF;

struct TapAPICommodity
{
TAPISTR_10 ExchangeNo;

TAPICommodityType CommodityType;

TAPISTR_10 CommodityNo;

};

struct TapAPIContract
{
TapAPICommodity Commodity;

TAPISTR_10 ContractNo1;

TAPISTR_10 StrikePrice1;

TAPICallOrPutFlagType CallOrPutFlag1;

TAPISTR_10 ContractNo2;

TAPISTR_10 StrikePrice2;

TAPICallOrPutFlagType CallOrPutFlag2;

};

struct TapAPIQuoteWhole
{
TapAPIContract Contract;

TAPISTR_10 CurrencyNo;

TAPICHAR TradingState;

TAPIDTSTAMP DateTimeStamp;

TAPIQPRICE QPreClosingPrice;

TAPIQPRICE QPreSettlePrice;

TAPIQVOLUME QPrePositionQty;

TAPIQPRICE QOpeningPrice;

TAPIQPRICE QLastPrice;

TAPIQPRICE QHighPrice;

TAPIQPRICE QLowPrice;

TAPIQPRICE QHisHighPrice;

TAPIQPRICE QHisLowPrice;

TAPIQPRICE QLimitUpPrice;

TAPIQPRICE QLimitDownPrice;

TAPIQVOLUME QTotalQty;

TAPIQPRICE QTotalTurnover;

TAPIQVOLUME QPositionQty;

TAPIQPRICE QAveragePrice;

TAPIQPRICE QClosingPrice;

TAPIQPRICE QSettlePrice;

TAPIQVOLUME QLastQty;

TAPIQPRICE QBidPrice[20];

TAPIQVOLUME QBidQty[20];

TAPIQPRICE QAskPrice[20];

TAPIQVOLUME QAskQty[20];

TAPIQPRICE QImpliedBidPrice;

TAPIQVOLUME QImpliedBidQty;

TAPIQPRICE QImpliedAskPrice;

TAPIQVOLUME QImpliedAskQty;

TAPIQPRICE QPreDelta;

TAPIQPRICE QCurrDelta;

TAPIQVOLUME QInsideQty;

TAPIQVOLUME QOutsideQty;

TAPIQPRICE QTurnoverRate;

TAPIQVOLUME Q5DAvgQty;

TAPIQPRICE QPERatio;

TAPIQPRICE QTotalValue;

TAPIQPRICE QNegotiableValue;

TAPIQDIFF QPositionTrend;

TAPIQPRICE QChangeSpeed;

TAPIQPRICE QChangeRate;

TAPIQPRICE QChangeValue;

TAPIQPRICE QSwing;

TAPIQVOLUME QTotalBidQty;

TAPIQVOLUME QTotalAskQty;

};

请问TapAPIContract怎么转换成C#的对应类型,我转换的时候已经成功转换了char数组。字符显示正常,但是double和long等数值类的类型全都不对。急急急~

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答