⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update.pas

📁 autoupdate 1.02 source code
💻 PAS
字号:
unit update;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, UProgressKnown, InfoIn, AutoUpdate;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    AutoUpdate1: TAutoUpdate;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure AutoUpdate1DebugMethod(S: String);
  private
    { Private declarations }
  public
    { Public declarations }
//    CurrentVersion : String;
//    VersionNo : Integer;

//   Info : TInfoIn;

    procedure Debug(S : String);

  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
   Progress : TProgressKnown;
begin
{   // check server for new version
   Progress := TProgressKnown.Create(self);
   try
      Progress.AutoClose := True;
      Progress.Execute(wtCheckVersion, Info);
      if Info.GetResult = irOK then
      begin
         // We have done the delete.
      end;
   finally
      Info.ClearResult;
      Progress.Free;
   end;}
end;

procedure TForm1.FormCreate(Sender: TObject);
var
    LockFile : String;
    h : THandle;

   function GetTempPath : String;
   var
      L : Integer;
   begin
      L := 256;
      SetLength(Result, L);
      L := Windows.GetTempPath(L, PChar(Result));
      SetLength(Result, L);
   end;
begin

   // check for multi instance
   LockFile := GetTempPath + 'autoupdate.lock';
   h := CreateFile(PChar(LockFile), GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0);
   if h = INVALID_HANDLE_VALUE then
   begin
      MessageDlg('The ITIG Autoupdte utility is already running.  You can only run one instance of this program at a time.', mtInformation, [mbOK], 0);

      Close;
      Application.Terminate;
      exit;
   end;

   //if ParamStr(1) = '-debug' then
   begin
      Memo1.Visible := True;
   end;

   Screen.Cursor := crHourGlass;
   Application.ProcessMessages;
//   Info := TInfoIn.Create(Handle, Debug);
   Screen.Cursor := crDefault;

//   AppName := 'test';
//   CurrentVersion := '0.1';
//   VersionNo := 1;

end;

procedure TForm1.Debug(S : String);
begin
   if Assigned(Memo1) then
   begin
      if Memo1.Visible then
      begin
         S := DateTimeToStr(now) + ' - ' + S;
         Memo1.Lines.Add(S);
{         if Assigned(Info) then
         begin
            Info.log(S);
         end;}
      end;
   end;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
   AutoUpdate1.CheckForUpgrade;
end;

procedure TForm1.AutoUpdate1DebugMethod(S: String);
begin
   Debug(s);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -