Last active
August 26, 2016 17:04
-
-
Save shturm/760bfb3d4bd3f17ad9f7166504bb9af6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Runtime.InteropServices; | |
using RGiesecke.DllExport; // https://www.nuget.org/packages/UnmanagedExports - required for the functions to be consumed by native code | |
namespace Testme | |
{ | |
class Test | |
{ | |
[DllExport("Add", CallingConvention = CallingConvention.StdCall)] | |
public static int Add(int left, int right) | |
{ | |
return left + right; | |
} | |
[DllExport("Sub", CallingConvention = CallingConvention.StdCall)] | |
public static int Sub(int left, int right) | |
{ | |
return left - right; | |
} | |
[DllExport("AddDouble", CallingConvention = CallingConvention.StdCall)] | |
public static double AddDouble(double left, double right) | |
{ | |
return left + right; | |
} | |
[DllExport("AddFloat", CallingConvention = CallingConvention.StdCall)] | |
public static float AddFloat(float left, float right) | |
{ | |
return left + right; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| UnmanagedExportsDLLExample1.mq5 | | |
//| Copyright 2010, Investeo.pl | | |
//| http:/Investeo.pl | | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright 2010, Investeo.pl" | |
#property link "http:/Investeo.pl" | |
#property version "1.00" | |
#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 | |
//+------------------------------------------------------------------+ | |
//| Script program start function | | |
//+------------------------------------------------------------------+ | |
void OnStart() | |
{ | |
//--- | |
for(int i=0; i<3; i++) | |
{ | |
Print(Add(i,666)); | |
Print(Sub(666,i)); | |
Print(AddDouble(666.5,i)); | |
Print(AddFloat(666.5,-i)); | |
} | |
} | |
//+------------------------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment