Que tal Gente.
Estoy tratando de hacer un actualizador para mi aplicación,
para ello me valí de algunos datos que recopile de otros hilos,
con uno descargo un archivo txt de una web con la version disponible,
y luego obtengo la version de mi programa en ejecución.
Aquí el codigo de Neftali para ver la version disponible en el servidor
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
var
b:Boolean;
TS:TStrings;
Str:String;
function DownloadFile(Source, Dest: string): Boolean;
begin
try
Source := AnsiReplaceStr(Source, '/', '\');
Result := UrlDownloadToFile(nil, PChar(Source), PChar(Dest), 0, nil) = 0;
except
Result := False;
end;
end;
begin
b := DownloadFile('http://neftali.clubdelphi.com/temp/test_vrs.txt',
'c:\temp\test_vrs.txt');
if (b) then begin
TS := TStringList.Create();
TS.LoadFromFile('c:\temp\test_vrs.txt');
Str := TS[1];
MessageDlg('Versión en el Servidor: ' + Str, mtInformation, [mbOK], 0);
TS.Free;
end;
end;
Y aquí la función que me dice ¿que versión estoy ejecutando?
Código Delphi
[-]
uses
Windows, SysUtils;
function GetAppVersion : string;
begin
Size := GetFileVersionInfoSize(PChar (ParamStr (0)), Size2);
if Size > 0 then
begin
GetMem (Pt, Size);
try
GetFileVersionInfo (PChar (ParamStr (0)), 0, Size, Pt);
VerQueryValue (Pt, '\', Pt2, Size2);
with TVSFixedFileInfo (Pt2^) do
begin
Result:= ' Versión '+
IntToStr (HiWord (dwFileVersionMS)) + '.' +
IntToStr (LoWord (dwFileVersionMS)) + ' Build ' +
IntToStr (HiWord (dwFileVersionLS)) + '.' +
IntToStr (LoWord (dwFileVersionLS));
end;
finally
FreeMem (Pt);
end;
end;
end;
El tema es que con la primera Funcion descargo el TXT en el cual coloco los numeros de version (ej 1.0.2.4) eso esta bien.
Pero la segunda función me da como resultado VERSION 1.0 BUILD 2.4.
De que forma puedo obtener la versión actual en NUMERO, cosa de comparar
if VERSIONDISPONIBLE > VERSIONACTUAL then ACTUALIZAR.
Gracias!