Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I made one dll that try call some function from metatrader platform.:

C++
#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
Posted
Comments
Volynsky Alex 14-Oct-12 10:45am    
A C0000005 Error is a Windows System error. It is an Exception Error that occurs when a process (application, driver, etc.) tries to execute a processor command that references memory outside the space allocated to that process by the Operating System.
There are many possible causes ranging from corrupt data tables, to a bad network connection, ActiveX controls, or Printer or Video driver errors. WIthout knowing what type of error you are seeing, it is impossible to guess what the cause may be.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900