1998-11-04 18:04:26 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2003-05-26 13:00:26 +00:00
|
|
|
#include <stdio.h>
|
1998-11-04 18:04:26 +00:00
|
|
|
|
2003-06-11 14:19:42 +00:00
|
|
|
void Renamer(const char* mask)
|
2003-05-26 13:00:26 +00:00
|
|
|
{
|
|
|
|
WIN32_FIND_DATA data;
|
2003-06-11 14:19:42 +00:00
|
|
|
HANDLE hHandle = ::FindFirstFile(mask, &data);
|
2003-05-26 13:00:26 +00:00
|
|
|
BOOL bRunning = hHandle != INVALID_HANDLE_VALUE;
|
|
|
|
while (bRunning)
|
1998-11-04 18:04:26 +00:00
|
|
|
{
|
2003-05-26 13:00:26 +00:00
|
|
|
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);
|
2004-05-05 13:54:46 +00:00
|
|
|
::MessageBox(NULL, msg, "Aggiornamento sistema", MB_ICONERROR | MB_OK);
|
2003-05-26 13:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bRunning = ::FindNextFile(hHandle, &data);
|
1998-11-04 18:04:26 +00:00
|
|
|
}
|
2003-06-11 14:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PASCAL WinMain(HINSTANCE, HINSTANCE , LPSTR, int)
|
|
|
|
{
|
2004-05-05 13:54:46 +00:00
|
|
|
::MessageBox(NULL, "Premere OK prima di riavviare il programma",
|
|
|
|
"Aggiornamento sistema", MB_ICONWARNING | MB_OK);
|
|
|
|
// ::Sleep(5000); // Apetta qualche secondo che termini ba0.exe
|
1998-11-04 18:04:26 +00:00
|
|
|
|
2003-06-11 14:19:42 +00:00
|
|
|
Renamer("*.??_");
|
|
|
|
Renamer("Servers\\*.??_");
|
|
|
|
|
2004-05-13 15:12:14 +00:00
|
|
|
WinExec("ba0.exe", SW_SHOWNORMAL);
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|