Download MetaTrader 5
To add comments, please log in or register
Deposit to your account using bank cards via Gate2Shop
Piotr
1256
Piotr 2010.02.24 20:51 
How to write Expert Advisor using DLL file ?
bernd
977
bernd 2010.02.24 21:02  
please be more precise. What exactly is the problem?
Piotr
1256
Piotr 2010.02.27 11:15  
7bit:
please be more precise. What exactly is the problem?

Hi I would like to secure code of the EA what I wrote it for my customer. I heard about extern DLL file... but how to compile it and attache to Meta Trader as the Expert Advisor program then...?

Walter
158
Walter 2010.02.27 12:21  
puncher wrote >>
How to write Expert Advisor using DLL file ?

Please read https://docs.mql4.com/runtime/imports and https://docs.mql4.com/basis/preprosessor/import

Piotr
1256
Piotr 2010.03.02 23:36  

Hi brother3th,


I have one question to you:


Should I add also the libraries user32.dll & stdlib.ex4 whenever I add my extern DLL file with functions used in Expert Advisor ?


#import "user32.dll"
int MessageBoxA(int hWnd, string lpText, string lpCaption, int uType);

#import "stdlib.ex4"
string ErrorDescription(int error_code);
int RGB(int red_value, int green_value, int blue_value);
bool CompareDoubles(double number1, double number2);
string DoubleToStrMorePrecision(double number, int precision);
string IntegerToHexString(int integer_number);

#import "ExpertSample.dll"
int GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[], int, int);
bool SetArrayItemValue(double& arr[], int,int, double);
double GetRatesItemValue(double rates[][6], int, int, int);
int SortStringArray(string& arr[], int);
int ProcessStringArray(string& arr[], int);
#import
gordon
2322
gordon 2010.03.03 05:19  
puncher:

Should I add also the libraries user32.dll & stdlib.ex4 whenever I add my extern DLL file with functions used in Expert Advisor ?


#import "user32.dll"
int MessageBoxA(int hWnd, string lpText, string lpCaption, int uType);

#import "stdlib.ex4"
string ErrorDescription(int error_code);
int RGB(int red_value, int green_value, int blue_value);
bool CompareDoubles(double number1, double number2);
string DoubleToStrMorePrecision(double number, int precision);
string IntegerToHexString(int integer_number);

#import "ExpertSample.dll"
int GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[], int, int);
bool SetArrayItemValue(double& arr[], int,int, double);
double GetRatesItemValue(double rates[][6], int, int, int);
int SortStringArray(string& arr[], int);
int ProcessStringArray(string& arr[], int);
#import

In your code u can see which functions are 'imported' from user32.dll and stdlib.ex4... If u don't use these functions, then no need to import them.

Piotr
1256
Piotr 2010.03.03 11:27  

Can I save all my functions in one extern DLL file and import it by expression: #include "file.dll" instead of #import "file.dll" ???


What are differences between #import and #include phrases in MQL code ?

gordon
2322
gordon 2010.03.03 12:00  
puncher:

Can I save all my functions in one extern DLL file and import it by expression: #include "file.dll" instead of #import "file.dll" ???


What are differences between #import and #include phrases in MQL code ?

#include just tells the preprocessor to add the code in the included file at that point BEFORE compilation -> https://docs.mql4.com/basis/preprosessor/include.

#import tells the code the correct function prototype, but the function is not "included" with the code... U still need the dll later when a function from it is called -> https://docs.mql4.com/basis/preprosessor/import.

Piotr
1256
Piotr 2010.03.03 14:30  

Thanks a LOT !

Piotr
1256
Piotr 2010.03.10 15:41  

One more question.

What kind of tool features should I compile a library file (where will be placed functions of the Expert Advisor) ?

gordon
2322
gordon 2010.03.10 16:18  
puncher:

One more question.

What kind of tool features should I compile a library file (where will be placed functions of the Expert Advisor) ?

If it's an MQL4 library - MetaEditor. If it's a DLL, then it depends on the programming-language, OS and on your IDE/Compiler of choice...

/ /123
To add comments, please log in or register