Files correlati :ba0.exe,ba0close.exe Ricompilazione Demo : [ ] Commento : Bug 0000162 relativo alle visualizzazioni del menu. Su ba0close cambiate alcune righe inutili. git-svn-id: svn://10.65.10.50/trunk@12075 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <windows.h>
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
 | 
						|
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, "Aggiornamento sistema", MB_ICONERROR | MB_OK);
 | 
						|
      }
 | 
						|
    }
 | 
						|
    
 | 
						|
    bRunning = ::FindNextFile(hHandle, &data);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int PASCAL WinMain(HINSTANCE, HINSTANCE , LPSTR, int)
 | 
						|
{
 | 
						|
  ::MessageBox(NULL, "Premere OK prima di riavviare il programma", 
 | 
						|
               "Aggiornamento sistema", MB_ICONWARNING | MB_OK);
 | 
						|
//  ::Sleep(5000); // Apetta qualche secondo che termini ba0.exe
 | 
						|
 | 
						|
  Renamer("*.??_");
 | 
						|
  Renamer("Servers\\*.??_");
 | 
						|
  
 | 
						|
  WinExec("ba0.exe", SW_SHOWNORMAL);
 | 
						|
 | 
						|
  return 0;
 | 
						|
}
 |