Ver Mensaje Individual
  #1  
Antiguo 21-03-2013
shoulder shoulder is offline
Miembro
 
Registrado: abr 2008
Posts: 441
Reputación: 17
shoulder Va por buen camino
Problema con Servicio para copiar programas

Hola tengo un problema, hice un servicio que actualiza los programas en el servidor de 4 a 5 de la mañana, el servicio funciona bien, compara si las versiones de los prg son distintas actualiza, el tema es que si un programa esta en uso o no lo puede copiar por algún problema se frena el servicio y no continua, cuando detengo el servicio termina de actualizar todo. Si pruebo el programa como un form comun aunque exista algun problema entre los prg a actualizar copia hasta el final. No se como solucionar esto.

Les dejo las funciones y como hice el prg. Gracias!!!!

El Servicio que copia el programa con un timer cada 5 minutos en ese lapso de horas :

Cita:
Procedure TServiceActua.Timer1Timer(Sender: TObject);

Var
V : TVSFixedFileInfo;
archiant, archipos : string;

begin

hora := copy(datetimetostr(now()),11,6);

if copy(datetimetostr(now()),13,1) = ':' then
hora := '0'+ copy(datetimetostr(now()),12,4);





hora1 := '04:57';

if ((strtotime(hora) > strtotime('03:57'))
and (strtotime(hora) < strtotime(hora1)) ) then
begin


V := GetFileVersion('\\xxx\Venta1\xxx\Pruebax.exe');

archiant:= Format('%d.%d',
[HiWord(V.dwFileVersionMS),
LoWord(V.dwFileVersionMS)]) ;



V := GetFileVersion('\\xxx\Venta1\Pruebax.exe');

archipos:= Format('%d.%d',
[HiWord(V.dwFileVersionMS),
LoWord(V.dwFileVersionMS)]) ;


if archiant <> archipos then
begin
copiatodo('\\xxx\Venta1\xxx\Pruebax.exe','\\xxx\Venta1\Pruebax.exe');
end;

archiant := '';
archipos := '';


V := GetFileVersion('\\xxx\Venta1\xxx\Prueba2.exe');

archiant:= Format('%d.%d',
[HiWord(V.dwFileVersionMS),
LoWord(V.dwFileVersionMS)]) ;



V := GetFileVersion('\\xxx\Venta1\Prueba2.exe');

archipos:= Format('%d.%d',
[HiWord(V.dwFileVersionMS),
LoWord(V.dwFileVersionMS)]) ;


if archiant <> archipos then
begin
copiatodo('\\xxx\Venta1\xxx\Prueba2.exe','\\xxx\Venta1\Prueba2.exe');
end;

end;


Funcion que Copia



Cita:
function CopiaTodo(Origen,Destino : String) : LongInt;
var
F : TShFileOpStruct;
sOrigen, sDestino : String;
begin
Result := 0;
sOrigen := Origen + #0;
sDestino := Destino + #0;

with F do
begin
Wnd := 0 ;
// Application.Handle;
wFunc := FO_COPY;
pFrom := @sOrigen[1];
pTo := @sDestino[1];
fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION
end;

Result := SHFileOperation(F);
end;
Cita:
Function GetFileVersion(AFileName : TFileName) : TVSFixedFileInfo;
Var
I : Cardinal;
P : Pointer;
Q : PChar;
Begin
I := GetFileVersionInfoSize(PChar(AFileName), I);
If (I > 0) Then
Begin
GetMem(P, I);
Try
GetFileVersionInfo(PChar(AFileName), 0, I, P);
VerQueryValue(P, '\', Pointer(Q), I);
Result := PVSFixedFileInfo(Q)^;
Finally
FreeMem(P);
End;
End
Else
FillChar(Result, SizeOf(TVSFixedFileInfo), #0);
End;

Última edición por shoulder fecha: 21-03-2013 a las 14:55:55. Razón: Error titulo
Responder Con Cita