C# exported function Problem

To add comments, please log in or register
termi_80
7
termi_80  

Hi all,

i create this simple function in c#:

  [DllExport("addminutes", CallingConvention = CallingConvention.StdCall)]
        public static string addminutes(int YY, int MM, int DD, int HH,int Mm, int Ss)
        {
            DateTime date = new DateTime(YY, MM, DD, HH, Mm, Ss);
            TimeSpan time = new TimeSpan(0, 0, 5, 0);
            DateTime combined = date.Add(time);
            string DataStringa = (combined.Hour + ":" + combined.Minute + ":" + combined.Second);
            return (DataStringa);
        }

i got in mql4 some strange character:

㜱㌺㨹5

Could you help me?

Davide

Anton Nel
50546
Anton Nel  

Try this C#:

using System.Text;

[DllExport("addminutes", CallingConvention = CallingConvention.StdCall)]
public static void addminutes(int YY, int MM, int DD, int HH,int Mm, int Ss, [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder strReturnValue)
{
   DateTime date = new DateTime(YY, MM, DD, HH, Mm, Ss);
   TimeSpan time = new TimeSpan(0, 0, 5, 0);
   DateTime combined = date.Add(time);
   string dataString = (combined.Hour + ":" + combined.Minute + ":" + combined.Second);
   strReturnValue.Append(dataString);
}


and this in MQL4:

#import "whatever.dll"
   int addminutes(int YY, int MM, int DD, int HH,int Mm, int Ss, string& strReturnValue);
#import

string strReturnValue = "";
addminutes(2017, 11, 07, 13, 20, 11, strReturnValue);
Print("addminutes: ", strReturnValue);
To add comments, please log in or register