How to secure MQL4 source code using the extern dll file ?

 
How to write Expert Advisor using DLL file ?
 
please be more precise. What exactly is the problem?
 
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...?

 
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

 

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
 
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.

 

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 ?

 
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.

 

Thanks a LOT !

 

One more question.

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

 
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...

Reason: