DLL Import : programs stops suddently

 

Hi


i'm trying to use a DLL to import functions for an Expert Advisor.


I originally tried the code in MT4 and it was working fine.

i followed this tuto to make it work in MT5 but as soon as i call any function from the DLL, the program suddently closes and the debugger also closes without any journal or debugging infos.


i created a new DLL from scratch with the tuto but no luck either : same problem.

Anyone has got this already?


I use Visual Studio Express 2010, Windows x64 but i compile in 32 bits because VSEX doesn't work in 64 bits. Also the DLL doesn't show in MetaEditor in the "Libraries" directory as it should


thanks for help


here is the codes i used:

#import "tempp.dll"
int fnCalculateSpeed(int res1,double res2);
#import
#include "stdafx.h"


//+------------------------------------------------------------------+
//|                                                 MQL5 DLL Samples |
//|                   Copyright 2001-2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#pragma once

#include "targetver.h"

#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
#include <windows.h>

//---
#define _DLLAPI extern "C" __declspec(dllexport)
//+------------------------------------------------------------------+
_DLLAPI int __stdcall fnCalculateSpeed(int res1,double res2)
  {
   return(0);
  }
 

If your DLL is built as 32-bit. It can only work with 32 bit MetaTrader 5.

You may refer to this post in the forum: https://www.mql5.com/en/forum/3523. See Renat's post there.

 

How to Install Metatrader 32bits in Windows 64 bits
How to Install Metatrader 32bits in Windows 64 bits
  • www.mql5.com
How to install Metatrader 32bits in Windows 64bits ? - - Category: general
 

yes but i couldn't know if it was 32 bit or 64 bits i has d installed, and i had troubles compiling to x64, but now it's okay (just had to set the include and lib paths to the correct folders (C:\Program Files\Microsoft SDKs\Windows\v7.1) on my machine


now everything works!!


thanks


Jeff