How to call a function from a DLL file from [ MQL5 ] code?



Why the first MessageBox() works and the second doesn't?

I don't know where the problem is.

Does the MQL5 can access the dll file?

I need to to call C# functions that read JSON.

No errors appear in MetaEditor.

C# .dll file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace TestMe
{
    class Test
    {

   // [DllExport("Add", CallingConvention =
CallingConvention.StdCall)]
    public static int Add(int left, int right)
    {
        return left + right;
    }


    public static int Sub(int left, int right)
    {
        return left - right;
    }


    public static double AddDouble(double left, double right)
    {
        return left + right;
    }


    public static float AddFloat(float left, float right)
    {
        return left + right;
    }
}
}

this is an MQL5 code:

#import "TestMe.dll"
                    int    Add(       int    left, int    right );
                    int    Sub(       int    left, int    right );
                    float  AddFloat(  float  left, float  right );
                    double AddDouble( double left, double right );
#import

#property strict                 // MQL-syntax-mode-modifier ==
"strict"

int OnInit()
{   int k = 0;
    MessageBox( k );             // this call works
    k = Add( 1, 666 );
    MessageBox( k );             // Doesn't work

    return( INIT_SUCCEEDED );
    }

Related to : How to call a function from a DLL file from [ MQL5 ] code?

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .