Discussion on "How to write a DLL for MQL5 and exchange data in 10 minutes". - page 8

 
avoitenko:

DLL function declaration

Calling a DLL function

Exactly! That's exactly what I did. Thank you!
 

In the last example, you also made some changes to the dll, didn't you?

That's what I mean.

bool ExcelSetTextCell(int X,int Y, uchar& Value[]);
 

Could you give me a hint as well, if it's not too much trouble. There is a dll, a text value is passed to it, the output is a number in type string

For example like this:

#import "n1.dll"
string fData (string a1);
#import

....

string znak = fData ("a");

// При значении "a" переменная znak будет равна например "172371", далее я значение znak конвертирую в int
// Так всё было в МТ4.

I can't fix the dll due to lack of knowledge. Please advise how to make a correct code for passing it to dll, and how to receive it correctly. I have a feeling that my dll will not work in MT5.

Thanks in advance for the help.

Документация по MQL5: Основы языка / Типы данных / Тип string
Документация по MQL5: Основы языка / Типы данных / Тип string
  • www.mql5.com
Основы языка / Типы данных / Тип string - Документация по MQL5
 
Killa:

Could you give me a hint as well, if it's not too much trouble. There is a dll, a text value is passed to it, the output is a number in type string

I cannot fix the dll due to lack of knowledge. Please advise how to correctly write the code to submit it to the dll, and how to get it properly. Because my dll doesn't work in MT5 right now.

Thanks in advance for your help.

I rechecked work with string return from DLL and found error in x64 (appeared after some optimizations). Correction will be included in the next build.

If you are working in x64, please wait for build release.

The only thing I can add, please remember that MQL5 works with Unicode strings.

 
Simply put, you have to rewrite the dll...
 
I want to feel the power of dlls, they talk about them a lot. The question is simple, where to start. What to download, what to read, which forum to go to, 5-6 points please. A lot in this life depends on the initial pendel.
 
Renat:

Published article How to write a DLL for MQL5 in 10 minutes and exchange data?:

Author: Renat Fatkhullin

Thanks for the article. I have already used it.

The tip is very good. But ! It took me 10 minutes to figure out how to set the DLL path correctly in VS2010.

It turned out to be like this:

C:\Users\пп\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Libraries

I suggest to copy path from MetaEditor.

Or specify your own path in enviroment (did not check it).

And another thing, how do we deal with multithreading?

 

Thanks for the article. Repeated it in full, but I want to say a few words about what I encountered during implementation - these seemingly small things almost put me off. What I wanted to clarify (using VS2010 + MT5 (32 bit) build 756 + Win 7 Maximum x64):

  1. I tried to connect it on the x64 platform and it failed - the reason, as I understand it, was the implicit dependence of the DLL created from standard Windows libraries, that for some reason loaded the x86 library - this is not an MQL5 problem, but still worth saying about it. I got out of this situation by installing MT5 32bit - it is done using command line "Installer folder"\mt5setup.exe /32. It will use x86 DLLs. Therefore I recommend to use only x86, at least at the beginning.
  2. MT5 couldn't find a plugin DLL in any way. The article says to put DLL in terminal Libraries folder, but terminal still can't see it. The solution is as follows: it does not matter where DLL will be stored, as long as the location is specified in system variables. How to do this will help Google.

Otherwise not a bad article... Respect!

 

On 64 bit MT5 example does not work. Terminal reports that it is 32-bit DLL and does not connect it. But under Win32 (as in this example and in all other examples - like in Delphi) - all DLLs are 32-bit. Like in previous post, I have to uninstall 64-bit version of the terminal and install 32-bit one. I also need to know how to do it since the 64-bit version is installed by force. It turns out that MT5 64 bits is a dead terminal, I do not know why it is released. Dear developers, if it is possible, please make it possible to connect a 32-bit DLL to МТ5 64 bits.

If this is technically impossible or difficult, write the pitfalls that this version will not work with 32-bit DLL and users suffer and can not understand what is wrong. And write openly that the folder Libraries is not in the directories of the terminal itself, and knows where, and without experience will not find, do not even try. By the way, in this secret place there are all indicators and experts, so installing MT5 you can forget about them - if you don't know that all this is in a hidden folder C:\Users\nAppData\Roaming... ...or the user thinks he's installing a well-written program, which is a hoax.

 

You should improve your technical level.

For 64-bit programs you need 64-bit libraries and there is no way you can reasonably connect 32-bit libraries. To install the 32 bit version, the installer must be run with the /32 switch

I will rewrite the article and add cool features that have long been implemented in MetaEditor and MT4 and MT5 platforms. Many developers are not aware of the new features.

Reason: