function TForm1.GetMyVersion: string; type TVerInfo=packed record Nevazhno: array[0..47] of byte; // 48 Minor,Major,Build,Release: word; // end; var s:TResourceStream; v:TVerInfo; begin result:=''; try s:=TResourceStream.Create(HInstance,'#1',RT_VERSION); // if s.Size>0 then begin s.Read(v,SizeOf(v)); // result:=IntToStr(v.Major)+IntToStr(v.Minor)+ // ... IntToStr(v.Release)+IntToStr(v.Build); end; s.Free; except; end; end;
if OpenDialog1.Execute then cxButtonEdit1.Text:=OpenDialog1.FileName;
var blobF: TBlobField; begin if not FileExists(OpenDialog1.FileName) then begin ShowMessage(' !'); exit; end else cxButtonEdit1.Text:=OpenDialog1.FileName; try ADOTable1.TableName:=Updater; // ADOTable1.Close; ADOTable1.Open; // name program ADOTable1.Filtered := False; ADOTable1.Filter := 'name='+#39+'program'+#39; ADOTable1.Filtered := True; ADOTable1.Edit; blobF := ADOTable1.FieldByName('files') as TBlobField; blobF.LoadFromFile(OpenDialog1.FileName); ADOTable1.FieldByName('version').AsString:=cxMaskEdit1.Text; ADOTable1.Post; except Showmessage(' !'); end;
Procedure TForm1.Update; var path,fullpath,Ourversion,LastVersion:string; blobF: TBlobField; begin // adoquery4.Active:=false; adoquery4.sql.text:='SELECT version FROM [dbo].[Updater] WHERE name='+#39+'program'+#39; adoquery4.Active:=true; // , Ourversion:=GetMyVersion; LastVersion:=adoquery4.FieldByName('version').Value; while pos('.',LastVersion)<>0 do delete(LastVersion,pos('.',LastVersion),1); // if strtoint(LastVersion)>strtoint(Ourversion) then If messageBox(Handle,' . ?','?', mb_YesNo or mb_iconquestion)=mrYes then try path:=ExtractFileDir(ParamStr(0)); if FileExists(path+'\Program.backup') then DeleteFile(path+'\Project2.backup'); RenameFile(path+'\Program.exe', path+'\Program.backup'); // // //ADOTable1 Updater ADOTable1.Close; ADOTable1.Open; ADOTable1.Filtered := False; ADOTable1.Filter := 'name='+#39+'program'+#39; ADOTable1.Filtered := True; ADOTable1.Active:=true; // blobF := ADOTable1.FieldByName('files') as TBlobField; if blobF.Value = nil then Exit; blobF.SaveToFile(path+'\Update_ARMTitan.zip'); ADOTable1.Active:=false; // with CreateInArchive(CLSID_CFormatZip) do begin OpenFile(ExtractFilePath(ParamStr(0)) + 'Update_ARMTitan.zip'); ExtractTo(ExtractFilePath(ParamStr(0))); Close; end; // DeleteFile(path+'\Update_ARMTitan.zip'); // fullpath:=path+'\Project2.exe'; ShellExecute(0, 'open', PWideChar(fullpath), '', nil, SW_SHOW); //WinExec(PAnsiChar(fullpath), SW_SHOW); Application.Terminate; // or: Close; finally end; end;
if FileExists(path+'\7z.dll') then begin ShowMessage(' 7z.dll'); exit; end;
or something else on the other.Source: https://habr.com/ru/post/152285/
All Articles