Calling functions from the dll and returning results - page 5

 
Protected is good, severely poor is bad. And with the ability to call a dll, how secure is it? :) Although of course you can prohibit call dll, etc. and so on. FindFirst and FindNext I needed when I had an idea to send a bunch of tasks for execution to the directory files of the Expert Advisor so it could look through them and execute. It turned out to be absurd.
 
And with the ability to invoke the dll, how secure is it? :)

Just look in the settings - everything is disabled (DLLs are disabled by default):

 
I am aware of that when I plugged in my dll. It's just that if you are allowed to import the dll, what kind of protection are you talking about?
 
By _default_ any import from a DLL is _completely_ forbidden_. This is the protection.
If one wants to use external DLLs, just enable the "Acknowledge each DLL function call" button and see what is being called. This is also protection. Just like protecting all embedded file operations with access only to /history and /files directories.
 
2 mike: sorry for the stupid question. I can't run dlls compiled in Delphi. I also encountered a similar problem with Pol ("Passing arrays and strings in DLL (Delphi)"), but no one answered it there. Can you tell how it was possible for you?
 
What's the problem? Here's an example of a dll that works (I've dropped everything irrelevant):

library MetaDLL;

uses
SysUtils,
Classes,
windows;

{$R *.res}

{-----Initialize-------------------------------------------------------------}
procedure InitDllData(CurrencyName: PChar); stdcall;
begin
// do something
end;

{-----Finalize---------------------------------------------------------------}
procedure FreeDllData; stdcall;
begin
// do something
end;

{-----Process tick-----------------------------------------------------------}
procedure ProcessTick(CurrencyName: PChar; bid, ask: double; time: integer); stdcall;
var
f: file;
DateTime: TDateTime;
begin
try
AssignFile(f, WorkDir + CurrencyName + '.tik');
try
reset(f, 1);
except
rewrite(f, 1);
end;

try
DateTime := MTTimeToNormal(time);
seek(f, FileSize(f));
BlockWrite(f, DateTime, sizeof(DateTime));
BlockWrite(f, bid, sizeof(bid));
finally
CloseFile(f);
end;
except
//
end;
end;


exports
ProcessTick, InitDllData, FreeDllData;

end.

Don't forget to set all your functions as stdcall, use only standard Windows types (strings only as PChar), also don't forget to specify in export directive all your exported functions and you will be happy.

Yes, and also look at the picture posted by Renat on how to allow the use of dll in EA.
 
I also forgot to add that the dll should be located in the <metatrader>\experts\libraries\ folder and connected in the Expert Advisor code like this:

#import "MetaDLL.dll"
void ProcessTick(string CurrencyName, double aBid, double aAsk, int aTime);
void InitDllData(string CurrencyName);
void FreeDllData();

and then you can call any function
 
Thanks for the help. Turns out it was just an incorrectly called array as a parameter of a function called from the dll
 
What's the problem? Here's an example of a dll that works (I took out all the irrelevant stuff):<br / translate="no">
library MetaDLL;

uses
SysUtils,
Classes,
windows;
...


Sorry for another silly question: Is it possible to use VCL in this DLL (to be more precise, was it possible for you)? Because when I connect "form" to ddl, MetaTrader still crashes with "error" at startup (or when connecting a corresponding Expert Advisor).
I'm actually only interested in TDatabase, TDataSource, TQuery
 
2 mike
I am very interested in your emulator, that you can practice on history. Unfortunately as far as I know MT is not going to make it. As I understand you do not really want to sell it because you make good money on Forex. But I've been looking for something similar on the web for a long time, so far without success. I would be glad if you let me use your development. From my part I can offer you MTS, perhaps it is the only thing that may interest you.
I hope for your cooperation, Alexander. f1-forum@mail.ru