我有以下代码,我在其中为variant.pvarval调用VariantInit方法,因为我将把varaint存储在另一个名为pval的变种中。因此,在将值存储到/*
#property "pragmas" help MQL4-compiler decide about setup of internal handlers
so this part of code "speaks" to MetaLang.exe at compile-time*/
#property indicator_buffers 3 // .DEF N-Buffs
#property indicator_color1 White // .SET Buf[0].color
#property indicator_color2 SeaGreen // .SET Buf[1].color
#property indicator_color3 FireBrick // .SET Buf[2].color
#property indicator_width1 1 // .SET Buf[0].width
#property indicator_width2 2 // .SET Buf[1].width
#property indicator_width3 2 // .SET Buf[2].width
double buffer_line_up[], // .DEF Arrays as dynamic ...[]
buffer_line_dn[], // with human-readable-names
buffer_line_ax[]; // and MT4 will take care
int init() {
SetIndexBuffer( 0, buffer_line_ax ); // .ASSOC IndexBuffer.0<-array[]
SetIndexLabel( 0, "SuperTrend" );
SetIndexBuffer( 1, buffer_line_up ); // .ASSOC IndexBuffer.0<-array[]
SetIndexLabel( 1, "Up Trend" );
SetIndexStyle( 1, DRAW_LINE,
STYLE_SOLID,
1 + int( ATR_Multiplier / 5 ),
SeaGreen
);
SetIndexBuffer( 2, buffer_line_dn ); // .ASSOC IndexBuffer.0<-array[]
SetIndexLabel( 2, "Down Trend" );
SetIndexStyle( 2, DRAW_LINE,
STYLE_SOLID,
1 + int( ATR_Multiplier / 5 ),
FireBrick
);
SetIndexDrawBegin(0, ATR_Period ); // .DEF initial depth of Buffer before 1st GUI output
IndicatorShortName( "xxxx[" + ATR_Period + "," + ATR_Multiplier + "]" );
IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ) );
之前,我正在为pVal->pvarVal
调用VariantInit
。但是电话pVal->pvarVal
正在崩溃。
VariantInit(pVal->pvarVal)
答案 0 :(得分:0)
来自在线帮助
VariantInit函数通过将vt成员设置为VT_EMPTY来初始化VARIANTARG。
此init函数不会将pvarVal初始化为任何有效的变量指针 所以在你的代码中你有 pVal-> vt = VT_VARIANT | VT_BYREF;
__int64 biNewVal = // Some logic here
pVal->pvarval=new VARIANT;
pVal->pvarVal->vt = VT_CY;
pVal->pvarVal->cyVal.int64 = biNewVal;
这样做会有效