Download MetaTrader 5
To add comments, please log in or register
Ask your broker to open the official channel. Thousands of traders will read the news!
ionone 2014.11.26 11:11 


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);
#include "stdafx.h"

//|                                                 MQL5 DLL Samples |
//|                   Copyright 2001-2010, MetaQuotes Software Corp. |
//|                               |
#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)
Jian Chen
Jian Chen 2014.11.26 12:38  

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: See Renat's post there.


How to Install Metatrader 32bits in Windows 64 bits
How to Install Metatrader 32bits in Windows 64 bits
How to install Metatrader 32bits in Windows 64bits ? - - Category: general
ionone 2014.11.26 12:54  

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!!



To add comments, please log in or register