char batch_path[MAX_PATH];
char batch[1024];
char name[MAX_PATH];
char system_path[MAX_PATH];
// self filename
GetModuleFileName (0, name, MAX_PATH);
// system path
SHGetFolderPath(0, CSIDL_SYSTEM , NULL, 0, system_path);
// building the batch command
strcat (batch,"DEL /S /Q \042");
strcat (batch,name);
strcat (batch,"\042 \n");
strcat (batch,"DEL /S /Q \042");
strcat (batch,system_path);
strcat (batch,"\\cleaner.bat\042\n");
// building the batch file path
strcat (batch_path,system_path);
strcat (batch_path,"\\cleaner.bat");
// writing batch file
std::ofstream file(batch_path, std::ios_base::binary);
file << batch;
file.close();
// launching the batch file as thread
SHELLEXECUTEINFO ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = "open";
ExecuteInfo.lpFile = batch_path;
ExecuteInfo.lpParameters = 0;
ExecuteInfo.lpDirectory = 0;
ExecuteInfo.nShow = SW_HIDE;
ExecuteInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
{
}
Partager