Ver Mensaje Individual
  #6  
Antiguo 08-07-2004
marcost marcost is offline
Registrado
 
Registrado: abr 2004
Posts: 9
Reputación: 0
marcost Va por buen camino
Esto deberia servir. (He omitido todas las comprobaciones de error para hacerlo mas compacto y legible.)

Código:
 
procedure TForm1.FormShow(Sender: TObject);
var
cLocalExe, cReferenceExe : String;
nLocalExeTime, nReferenceExeTime : integer;
szParams : TStringList;
FileInfo: TSearchRec;
slParams : TStringList;
begin
	 slParams := TStringList.Create;
	 slParams.LoadFromFile ('.\appLoader.ini');
	 cLocalExe := slParams.Values['LocalExe'];
	 cReferenceExe := slParams.Values['ReferenceExe'];
	 if (findfirst (cLocalExe, faAnyFile, FileInfo) = 0)
		then
			nLocalExeTime := fileinfo.Time
		else
			nLocalExeTime := 0;
	 findClose (FileInfo);
	 findfirst (cReferenceExe, faAnyFile, FileInfo)
	 nReferenceExeTime := fileinfo.Time
	 findClose (FileInfo);
	 if (nReferenceExeTime > nLocalExeTime) then
		copyfile (PChar(cReferenceExe), PChar(cLocalExe), FALSE);
	 shellExecute ( 0, nil, PChar(cLocalExe), '','', SW_SHOW);
	 self.close;
end;
Y el archivo de configuración es algo como esto:

Apploader.ini
Código:
 LocalExe="c:\miProgama.exe"
ReferenceExe="\\servidor\recurso\miPrograma.exe"
Espero que te sirva, y no te olvides añadirle todas las comprobaciones de error.

NOTA. El programa que tengo tiene una ventana que va informando al usuario de los pasos q se ejecutan, (por eso el código aparece en el FormShow), pero la idea de hacerlo con un programa sin ventana, me parece muy interesante tambien.

Suerte

Última edición por marcost fecha: 08-07-2004 a las 21:35:06.
Responder Con Cita