There should be Java enum for ErrMsgLang, and Java classes for WindData and CWAPIWrapperCpp
## The CPP File
#ifndef _WAPIWRAPPERCPP_H
#define _WAPIWRAPPERCPP_H
#include <windows.h>
#include <comutil.h>
#ifdef WAPIWRAPPERCPP_EXPORTS
#define WAPIWRAPPERCPP_EXP __declspec(dllexport)
#else
#define WAPIWRAPPERCPP_EXP __declspec(dllimport)
#endif
//ๆงไปถๆชๆณจๅ้่ฏฏ
const LONG noRegErr = -1;
enum ErrMsgLang //้่ฏฏไฟกๆฏ่ฏญ่จ
{
eENG = 0, ///< ่ฑ่ฏญ
eCHN, ///< ไธญๆ
};
class WAPIWRAPPERCPP_EXP WindData
{
public:
VARIANT data; ///< ๆฐๆฎ
VARIANT codes; ///< Codeๅ่กจ
VARIANT fields; ///< ๆๆ ๅ่กจ
VARIANT times; ///< ๆถ้ดๅ่กจ
LONG errorCode; ///< ้่ฏฏ็
public:
WindData();
~WindData();
VOID InitWindData();
VOID ClearWindData();
//่ทๅ้่ฏฏไฟกๆฏ
LPCWSTR GetErrorMsg() const;
//ๆฅๆ่ฝฌๅๅฝๆฐ(้่ฆdelete)
static WCHAR* DateToString(DATE date, LPCWSTR strFormat = L"%Y-%m-%d");
static VOID FreeString(WCHAR*& pStr);
//////////////////////////////////////////////////////////////////////////
//ๆฐๆฎไฝฟ็จ
INT GetCodesLength() const;
INT GetFieldsLength() const;
INT GetTimesLength() const;
LPCWSTR GetCodeByIndex(int index) const;
LPCWSTR GetFieldsByIndex(int index) const;
BOOL GetTimeByIndex(int index, WCHAR timeBuffer[], int& length) const;
DATE GetTimeByIndex(int index) const;
//่ทๅๆฐๆฎๆฅ่ฏขๆฅๅฃOneData
BOOL GetDataItem(int timeIndex, int codesIndex, int fieldsIndex, VARIANT& outItem) const;
//่ทๅๆฅๆๅ่กจ
const DATE* GetTDaysInfo(LONG& lDateCount) const;
//////////////////////////////////////////////////////////////////////////
//ไบคๆไฝฟ็จ
INT GetRecordCount() const;
//่ทๅไบคๆๆฅๅฃOneData
BOOL GetTradeItem(int recordIndex, int fieldsIndex, VARIANT& outItem) const;
//่ทๅ็ปๅฝID
LONG GetLogonID() const;
//่ทๅOrder่ฏทๆฑId
LONG GetOrderRequestID() const;
//่ทๅOrderNumber
LPCWSTR GetOrderNumber(int recordIndex = 0) const;
};
// ๅ่ฐๅฝๆฐๅฎไน
typedef LONG (WINAPI *WsqCallBack)(const WindData &windData);
// ๆญค็ฑปๆฏไป WAPIWrapperCpp.dll ๅฏผๅบ็
class WAPIWRAPPERCPP_EXP CWAPIWrapperCpp {
public:
//ๅบๆฌๅฝๆฐ
//////////////////////////////////////////////////////////////////////////
//Windๆฅๅฃๅฏๅจๅฝๆฐ
static LONG start(LPCWSTR options = NULL, LPCWSTR options2 = NULL, LONG timeout = 5000);
//Windๆฅๅฃ็ปๆญขๅฝๆฐ
static LONG stop();
//ๅคๆญ่ฟๆฅ็ถๆ
static LONG isconnected();
//่ฅ requestId ไธบ0 ๅๆถๆๆ่ฏทๆฑ๏ผๅฆๅๅชๅๆถ็ปๅฎIDๅท็่ฏทๆฑ
static VOID cancelRequest(ULONGLONG requestId);
//ๅๆถๆๆ่ฏทๆฑ
static VOID cancelAllRequest();
//่ทๅ้่ฏฏ็ ็ธๅบ็้่ฏฏไฟกๆฏ
static BOOL getErrorMsg(LONG errCode, ErrMsgLang lang, WCHAR msg[], int& /*inout*/msgLength);
//////////////////////////////////////////////////////////////////////////
//ๆฐๆฎๅฝๆฐ
//////////////////////////////////////////////////////////////////////////
//ๅคๅผๅฝๆฐwsd๏ผ่ทๅพๆฅๆๅบๅ
static LONG wsd(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime = NULL, LPCWSTR endTime = NULL, LPCWSTR options = NULL);
//ๅคๅผๅฝๆฐwss๏ผ่ทๅพๅๅฒๅฟซ็
ง
static LONG wss(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR options = NULL);
//ๅคๅผๅฝๆฐwsi๏ผ่ทๅพๅ้ๅบๅ
static LONG wsi(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);
//ๅคๅผๅฝๆฐwst๏ผ่ทๅพๆฅๅ
่ทณไปท
static LONG wst(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);
//ๅคๅผๅฝๆฐwsq๏ผ่ทๅพๅฎๆถ่กๆ
//้่ฎข้
ๆจกๅผ๏ผๅไธๆฌกๆงๅฟซ็
งๆฐๆฎ
static LONG wsq(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR options = NULL);
//่ฎข้
ๆจกๅผ๏ผ่ฎข้
ๅฎๆถๆฐๆฎ๏ผๆฐๆฎ้่ฟๅ่ฐๅฝๆฐ่ฟๅ
static LONG wsq(ULONGLONG &reqId, LPCWSTR windCodes, LPCWSTR fields, WsqCallBack callBack, LPCWSTR options = NULL, BOOL updateAllFields = FALSE);
//ๅคๅผๅฝๆฐwset๏ผ่ทๅพๆๅฎๆฐๆฎ้
static LONG wset(WindData& outWindData, LPCWSTR reportName, LPCWSTR options = NULL);
//ๅคๅผๅฝๆฐedb๏ผ่ทๅพ็ปๆตๆฐๆฎ
static LONG edb(WindData& outWindData, LPCWSTR windCodes, LPCWSTR startTime = NULL, LPCWSTR endTime = NULL, LPCWSTR options = NULL);
//็ปๅๆฅ่กจๅฝๆฐ
static LONG wpf(WindData& outWindData, LPCWSTR portfolioName, LPCWSTR viewName, LPCWSTR options = NULL);
//็ปๅไธไผ ๅฝๆฐ
static LONG wupf(WindData& outWindData, LPCWSTR portfolioName, LPCWSTR tradeDate, LPCWSTR windCodes, LPCWSTR quantity, LPCWSTR costPrice, LPCWSTR options = NULL);
//่ฏๅต็ญ้ๅฝๆฐ
static LONG weqs(WindData& outWindData, LPCWSTR planName, LPCWSTR options = NULL);
//ๆฅๅๆฅใๅทฅไฝๆฅใไบคๆๆฅ็ๆฅๆๅบๅๅฝๆฐ
static LONG tdays(WindData& outWindData, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);
//ๆฅๅๆฅใๅทฅไฝๆฅใไบคๆๆฅ็ๆฅๆๅ็งป่ฎก็ฎ
static LONG tdaysoffset(DATE& outDate, LPCWSTR startTime, LONG offset, LPCWSTR options = NULL);
//ๆฅๅๆฅใๅทฅไฝๆฅใไบคๆๆฅ็ๆฅๆๅคฉๆฐ่ฎก็ฎ
static LONG tdayscount(LONG& outCount, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);
//////////////////////////////////////////////////////////////////////////
//ไบคๆๅฝๆฐ
//////////////////////////////////////////////////////////////////////////
//ไบคๆ่ดฆๅท็ป้
static LONG tlogon(WindData& outWindData, LPCWSTR brokerID, LPCWSTR departmentID, LPCWSTR accountID, LPCWSTR password, LPCWSTR accountType, LPCWSTR options = NULL);
//ไบคๆ่ดฆๅท็ปๅบ, 0:็ปๅบๅ
จ้จๅทฒ็ปๅฝ็่ดฆๅท
static LONG tlogout(INT longId=0);
//ไธๅ
static LONG torder(WindData& outWindData, LPCWSTR windCodes, LPCWSTR tradeSide, LPCWSTR orderPrice, LPCWSTR orderVolume, LPCWSTR options = NULL);
static LONG torder(LONG& reqId, LPCWSTR windCodes, LPCWSTR tradeSide, DOUBLE orderPrice, LONG orderVolume, LPCWSTR options = NULL, WCHAR** pErrosMsg = NULL);
//ๅคๅ
static LONG tcovered(WindData& outWindData, LPCWSTR windCodes, LPCWSTR tradeSide, LPCWSTR orderVolume, LPCWSTR options = NULL);
static LONG tcovered(LONG& reqId, LPCWSTR windCodes, LPCWSTR tradeSide, LONG orderVolume, LPCWSTR options = NULL, WCHAR** pErrosMsg = NULL);
//ไบคๆๆ
ๅตๆฅ่ฏข
static LONG tquery(WindData& outWindData, LPCWSTR qryCode, LPCWSTR options = NULL);
//ๆคๅ
static LONG tcancel(LPCWSTR orderNumber, LPCWSTR options = NULL);
//////////////////////////////////////////////////////////////////////////
//ๅๆตๅฝๆฐ
//////////////////////////////////////////////////////////////////////////
//ๅๆตๅผๅง
static LONG bktstart(WindData& outWindData, LPCWSTR strategyName, LPCWSTR startDate, LPCWSTR endDate, LPCWSTR options = NULL);
//ๅๆตๆฅ่ฏข
static LONG bktquery(WindData& outWindData, LPCWSTR qrycode, LPCWSTR qrytime, LPCWSTR options = NULL);
//ๅๆตไธๅ
static LONG bktorder(WindData& outWindData, LPCWSTR tradeTime, LPCWSTR securityCode, LPCWSTR tradeSide, LPCWSTR tradeVol, LPCWSTR options = NULL);
//ๅๆต็ปๆ
static LONG bktend(WindData& outWindData, LPCWSTR options);
//ๆฅ็ๅๆต็ถๆ
static LONG bktstatus(WindData& outWindData, LPCWSTR options);
//ๅๆตๆฆ่ฆ
static LONG bktsummary(WindData& outWindData, LPCWSTR bktID, LPCWSTR view, LPCWSTR options);
//ๅๆตๅ ้ค
static LONG bktdelete(WindData& outWindData, LPCWSTR bktID, LPCWSTR options);
//่ฟๅ็ญ็ฅๅ่กจ
static LONG bktstrategy(WindData& outWindData, LPCWSTR options);
//////////////////////////////////////////////////////////////////////////
};
#endif