Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 766 git-svn-id: svn://10.65.10.50/trunk@14628 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			80 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <windows.h>
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
 | 
						|
void Renamer(const char* mask)
 | 
						|
{
 | 
						|
  char drive[_MAX_DRIVE], path[_MAX_PATH], fname[_MAX_FNAME], ext[_MAX_EXT];
 | 
						|
  _splitpath(mask, drive, path, NULL, NULL);
 | 
						|
 | 
						|
 | 
						|
  WIN32_FIND_DATA data;
 | 
						|
  HANDLE hHandle = ::FindFirstFile(mask, &data);
 | 
						|
  BOOL bRunning = hHandle != INVALID_HANDLE_VALUE;
 | 
						|
  while (bRunning)
 | 
						|
  {
 | 
						|
    _splitpath(data.cFileName, NULL, NULL, fname, ext);
 | 
						|
 | 
						|
    const char* newext = NULL;
 | 
						|
    if (stricmp(ext, ".ex_") == 0) 
 | 
						|
      newext = ".exe"; else
 | 
						|
    if (stricmp(ext, ".dl_") == 0) 
 | 
						|
      newext = ".dll";
 | 
						|
 | 
						|
    if (newext != NULL)
 | 
						|
    {
 | 
						|
      char oldpath[_MAX_PATH], newpath[_MAX_PATH];
 | 
						|
      _makepath(oldpath, drive, path, fname, ext);
 | 
						|
      _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 cmd_line, int)
 | 
						|
{
 | 
						|
  ::MessageBox(NULL, "Premere OK ed attendere il riavvio del programma", 
 | 
						|
               "Aggiornamento sistema", MB_ICONWARNING | MB_OK);
 | 
						|
  ::Sleep(3000); // Apetta qualche secondo che termini ba0.exe
 | 
						|
 | 
						|
  Renamer("*.??_");
 | 
						|
  Renamer("Servers\\*.??_");
 | 
						|
 | 
						|
	int modules_pending = ::GetPrivateProfileInt("ba0close", "ModulesPending", 0, "./campo.ini");
 | 
						|
  
 | 
						|
	if (modules_pending != 0)
 | 
						|
	{
 | 
						|
		char cmd[256];
 | 
						|
		strcpy(cmd, "ba1.exe -6 /u");
 | 
						|
		const char* u = strstr(cmd_line, "/u");
 | 
						|
		if (u != NULL)
 | 
						|
			strcat(cmd, u+2);
 | 
						|
		else
 | 
						|
			strcat(cmd, "ADMIN");
 | 
						|
 | 
						|
		WinExec(cmd, SW_SHOWNORMAL);
 | 
						|
	}
 | 
						|
	else
 | 
						|
		WinExec("ba0.exe", SW_SHOWNORMAL);
 | 
						|
 | 
						|
  return 0;
 | 
						|
}
 |