#include #include void Renamer(const char* mask) { WIN32_FIND_DATA data; HANDLE hHandle = ::FindFirstFile(mask, &data); BOOL bRunning = hHandle != INVALID_HANDLE_VALUE; while (bRunning) { const char* newext = NULL; const char* oldpath = data.cFileName; char drive[_MAX_DRIVE], path[_MAX_PATH], fname[_MAX_FNAME], ext[_MAX_EXT]; _splitpath(oldpath, drive, path, fname, ext); if (stricmp(ext, ".ex_") == 0) newext = ".exe"; else if (stricmp(ext, ".dl_") == 0) newext = ".dll"; if (newext != NULL) { char newpath[_MAX_PATH]; _makepath(newpath, drive, path, fname, newext); if (::CopyFile(oldpath, newpath, FALSE)) { ::DeleteFile(oldpath); } else { char msg[512]; LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL); sprintf(msg, "Impossibile ridenominare il file %s in %s:\n%s", oldpath, newpath, lpMsgBuf); ::LocalFree(lpMsgBuf); ::MessageBox(NULL, msg, "Ba0Close Error", MB_ICONERROR | MB_OK); } } bRunning = ::FindNextFile(hHandle, &data); } } int PASCAL WinMain(HINSTANCE, HINSTANCE , LPSTR, int) { ::Sleep(5000); // Apetta qualche secondo che termini ba0.exe Renamer("*.??_"); Renamer("Servers\\*.??_"); return 0; }