Download MetaTrader 5

Dll, write by Borland Delphi. Can't work in MT5.

To add comments, please log in or register
jim_sg
11
jim_sg  

dll file ================================

library TestDll;


uses
  ShareMem, SysUtils, Classes;

  function TestDll_A(i: integer): integer; stdcall;
  begin
    Result := i * 100;
  end;
  function TestDll_B(aStr: PChar): integer; stdcall;
  begin
//    StrCopy(aStr, PChar('123'));

    StrCopy(aStr, PChar('in dll in dll'));

    Result := 0;
  end;

exports
  TestDll_A, TestDLL_B;

{$R *.res}

begin

end.

 


mt5 file ================================

//+------------------------------------------------------------------+
//|                                                      TestDll.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#import "TestDll.dll"
  int TestDll_A(int i);
  int TestDll_B(string &aStr);
#import


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
//---
   string te = "MQL5 string MQL5 string";
   Print("123456789");
   Print(TestDll_A(30));
   Print("123456789");     
   TestDll_B(te);
   Print(te);
   Print("123456789");     
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  
  }
//+------------------------------------------------------------------+

=============================================

When I was in borland Delphi to call this DLL, can show normal, when I MT5 were called, only showed non-normal character.

How can I do? Thanks!

Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Ilyas
1208
Ilyas  

About string type (link)

The string type is used for storing text strings. A text string is a sequence of characters in the Unicode format with the final zero at the end of it.A string constant can be assigned to a string variable. A string constant is a sequence of Unicode characters enclosed in double quotes: "This is a string constant".

jim_sg
11
jim_sg  
mql5:

About string type (link)

 Thanks, I will try, I do renounce the use of DLL, only in the MT5 in string handling.
To add comments, please log in or register