Files correlati : ba0close.exe Ricompilazione Demo : [ ] Commento : Rinominate anche le eventuali DLL dei servers dopo un aggiornamento git-svn-id: svn://10.65.10.50/trunk@11229 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.5 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, "Ba0Close Error", MB_ICONERROR | MB_OK);
 | 
						|
      }
 | 
						|
    }
 | 
						|
    
 | 
						|
    bRunning = ::FindNextFile(hHandle, &data);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int PASCAL WinMain(HINSTANCE, HINSTANCE , LPSTR, int)
 | 
						|
{
 | 
						|
  ::Sleep(1000); // Apetta un secondo che termini ba0.exe
 | 
						|
 | 
						|
  Renamer("*.??_");
 | 
						|
  Renamer("Servers\\*.??_");
 | 
						|
  
 | 
						|
  return 0;
 | 
						|
}
 |