الاكواد اللى كتبها الاستاذ deloryan
جميلة جدا شكرا ليه وعلى اهتمامه بافادة الجميع
int PROTECT()
{
/* Password protection code:
This the widely used method to protect softwares in general and can be used
to protect MQL4 programs.
When the user buy your program you send him the program with
a password and he can use the program without the password.
This is a simple code to apply password protection method:
*////////
string Password = "0";
// your code here....
if (Password != "viva metatrader") //change to the password you give the user!
{
Alert ("Wrong password!");
return (0); }
/*
In the code above the password is "viva metatrader" which is
hard coded in the MQL4 file. You have to compile the program after
adding this piece of code and send it to the user with the password.
Trial period protection:
If you want to give the user of the program a try-before-buy program you can limit
the usage of your program by limited period of time and after this period
the program will not work.
Use the code below to limit your program for period of time.
*/////
string expire_date = "2006.31.06"; //<-- hard coded datetime
datetime e_d = StrToTime(expire_date);
if (CurTime() >= e_d)
{
Alert ("The trial version has been expired!");
return(0); }
/*
Limited account number protection:
In this method of protection you will ask the user to give you his account
number and you write the following code to prevent the program to work with
another accounts:
*////
int hard_accnt = 11111; //<-- type the user account here before compiling
int accnt = AccountNumber();
if (accnt != hard_accnt)
{
Alert ("You can not use this account (" + DoubleToStr(accnt,0) + ") with this program!");
return(0); }
/*
Limited account type protection:
In this method of protection you will allow the user to use the program in demo mode
only and prevent him to use the program in live trading. Its not strong protection
because the user can host the program in another instance of MetaTrader that runs in
demo mode and trade manually in the real account instance.
*//////
bool demo_account = IsDemo();
if (!demo_account)
{
Alert ("You can not use the program with a real account!");
return(0);
}
// your normal code!
return(0);
}

