Hi,
I made one dll that try call some function from metatrader platform.:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <cstring>
using namespace std;
#define MT4_EXPFUNC __declspec(dllexport)
struct MqlStr
{
int len;
char *string;
};
vector<char*> hsymbol;
vector<char*> hcomment;
vector<double>hsl;
vector<double>htp;
vector<double>hopenprice;
vector<double>hcloseprice;
vector<int>hticket;
vector<int>hopentime;
vector<int>hclosetime;
vector<int>hordertype;
vector<int>hmagic;
vector<double>horderprofit;
int htotal=0;
MT4_EXPFUNC void __stdcall history(double *h_tp,double *h_sl,int *h_ticket,double *h_openprice,
double *h_closeprice,int *h_opentime,int *h_closetime,int *h_ordertype, MqlStr *h_symbol,
MqlStr *h_comment,int *h_magic,double *h_orderprofit, int hordertotal)
{
htotal=hordertotal;
hsymbol.clear();
hcomment.clear();
hsl.clear();
htp.clear();
hopenprice.clear();
hcloseprice.clear();
hticket.clear();
hopentime.clear();
hclosetime.clear();
hordertype.clear();
hmagic.clear();
horderprofit.clear();
hsymbol.resize(htotal);
hcomment.resize(htotal);;
hsl.resize(htotal);
htp.resize(htotal);
hopenprice.resize(htotal);
hcloseprice.resize(htotal);
hticket.resize(htotal);
hopentime.resize(htotal);
hclosetime.resize(htotal);
hordertype.resize(htotal);
hmagic.resize(htotal);
horderprofit.resize(htotal);
for(int i=0;i<htotal;i++){
htp[i]=h_tp[i];
hopenprice[i]=h_openprice[i];
hcloseprice[i]=h_closeprice[i];
hticket[i]=h_ticket[i];
hopentime[i]=h_opentime[i];
hclosetime[i]=h_closetime[i];
hordertype[i]=h_ordertype[i];
hmagic[i]=h_magic[i];
horderprofit[i]=h_orderprofit[i];
}
return;
}
When make dll I have not any errors.
After call function history get this error:
function 'history' call from dll 'Test.dll' critical error c0000005 at 61BB16EC.
This error is related to my code or any problem in my OS(win7)?
I tried using Fixed array variables instead vector but same error.
How I can fix this?
Regardsm