📄 update.pas
字号:
unit update;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShlObj,ShellAPI,IniFiles,UrlMon, StdCtrls;
const IconEvent = WM_USER + 1000;
type
TFrmUpdate = class(TForm)
Lblinfo: TLabel;
BtnClose: TButton;
BtnOpen: TButton;
procedure FormCreate(Sender: TObject);
procedure BtnCloseClick(Sender: TObject);
procedure BtnOpenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmUpdate: TFrmUpdate;
NTIDA:TNotifyIcondataA;
implementation
{$R *.dfm}
function DownloadFile(SourceFile, DestFile: string):Boolean;
begin
try Result := UrlDownloadToFile(nil, PChar(SourceFile),PChar(DestFile), 0, nil) = 0;
except Result := False;
end;
end;
procedure TFrmUpdate.FormCreate(Sender: TObject);
var
UpdateIniFile:TIniFile;
DownPath:string;
i,num:integer;
begin
NTIDA.cbSize := SizeOf(TNotifyIconDataA);
NTIDA.Wnd := Handle;
NTIDA.uID := 100;
NTIDA.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE;
NTIDA.hIcon := Application.Icon.handle;
NTIDA.szTip := 'Ukiller 更新中...';
Shell_NotifyIconA(NIM_ADD,@NTIDA);
UpdateIniFile:=TInifile.Create(ExtractFilePath(Application.ExeName)+'update.ini');
num:= UpdateIniFile.ReadInteger('Update','Num',1);
for i:=1 to num do
begin
DownPath:=UpdateIniFile.ReadString('Update','Url'+intTostr(i),'');
if DownloadFile(DownPath,ExtractFilePath(Application.ExeName)+ExtractFileName(DownPath))then
begin
FrmUpdate.Lblinfo.caption:=ExtractFileName(DownPath)+'更新成功! ';
sleep(1000);
end
else FrmUpdate.Lblinfo.caption:='更新失败,请检查网络! ';;
end;
end;
procedure TFrmUpdate.BtnCloseClick(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NTIDA);
Application.Terminate;
end;
procedure TFrmUpdate.BtnOpenClick(Sender: TObject);
begin
ShellExecute(Application.Handle,PChar('open'),PChar(ExtractFilePath(Application.ExeName)+'Ukiller.exe'),PChar(''),nil,SW_NORMAL);
sleep(1000);
Shell_NotifyIcon(NIM_DELETE,@NTIDA);
Application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -