?? p_client.pas
字號:
unit p_Client;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, ADODB, ExtCtrls,
Controls, Forms,Dialogs, DB,ShellApi, StdCtrls, ComCtrls,iniFiles, XPMan;
type
Tfrm_Client = class(TForm)
Label1: TLabel;
lb_cxName: TLabel;
Label2: TLabel;
lb_cxSize: TLabel;
Label4: TLabel;
Timer: TTimer;
sp_se_cxVersion: TADOStoredProc;
wqdata: TADOConnection;
Label3: TLabel;
sp_se_cxnow: TADOStoredProc;
XPManifest1: TXPManifest;
procedure TimerTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_Client: Tfrm_Client;
D:String ='.';
bz:Integer=0;
i:Integer= 0;
Const
Str:String ='程序正在更新';
cxVersion:String = '0';
CurrName:String ='人事科招聘人員工資管理系統(tǒng) 成都萬全數(shù)據(jù)有限公司';
implementation
uses p_cxThread;
{$R *.dfm}
procedure Tfrm_Client.TimerTimer(Sender: TObject);
var
Myini:TIniFile;
zcx:String;
zcxmc:String;
CurrHwnd:HWND;
begin
if Length(Label4.Caption) < 40 then
Label4.Caption := Label4.Caption+D
else
Label4.Caption := Str;
if bz=1 then
begin
Label4.Caption := '程序下載完成!';
Sleep(1000);
if not FileExists(ExtractFilePath(ParamStr(0))+'UpdateIni.ini') then
begin
Application.MessageBox('由于"UpdateIni.ini"文件丟失,更新文件失敗!','提示',0+16);
Application.Terminate;
Exit;
end;
Myini:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'UpdateIni.ini');
zcx:= Myini.ReadString('Curr','FilePath','');
zcxmc:=Myini.ReadString('Curr','FileName','');
if zcx = '' then
begin
Application.MessageBox('由于文件丟失,更新文件失敗!','提示',0+16);
Application.Terminate;
Exit;
end;
CurrHwnd:= FindWindow(nil,PAnsiChar(CurrName));
While CurrHwnd <> 0 do
begin
SendMessage(CurrHwnd,WM_CLOSE,0,0);
Sleep(500);
inc(i);
if i = 30 then
begin
Application.MessageBox('當前更新程序正在使用,請關閉其它相同程序后在使用!','提示',0+16);
Application.Terminate;
Exit;
end;
CurrHwnd:=FindWindow(nil,PAnsiChar(CurrName));
end;
deleteFile(zcx+zcxmc);
Sleep(1000);
ReNameFile(ExtractFilePath(ParamStr(0))+'\Temp.exe',zcxmc);
if FileExists(ExtractFilePath(ParamStr(0))+'\Temp.exe') then
begin
ReNameFile(ExtractFilePath(ParamStr(0))+'\Temp.exe',zcxmc);
end;
ShellExecute(Handle,'Open',PAnsiChar(zcx+zcxmc),nil,nil, SW_SHOWNORMAL);
Myini.Free;
Application.Terminate;
end;
if bz=2 then
begin
Label4.Caption := '程序更新失敗,請手動更新程序!';
Application.Terminate;
Timer.Enabled := False;
end;
end;
procedure Tfrm_Client.FormCreate(Sender: TObject);
begin
with sp_se_cxnow do
begin
Close;
Parameters.ParamByName('@cxNO').Value := 2;
Open;
end;
if sp_se_cxnow.RecordCount = 0 then
begin
Application.MessageBox('沒有找到更新文件,請手動更新!','提示',0+16);
Exit;
end;
lb_cxName.Caption := sp_se_cxnow.FIeldByName('cxName').AsString;
lb_cxSize.Caption := IntToStr(Round(sp_se_cxnow.FieldByName('cxSize').AsInteger/1024))+'/KB';
if not FileExists(ExtractFilePath(ParamStr(0))+'UpdateIni.ini') then
begin
Application.MessageBox('沒有找到UpdateIni.ini文件,請手動更新!','提示',0+16);
Application.Terminate;
Exit;
end;
if not wqdata.Connected then
wqdata.Connected := True;
cxThread.Create(False);
Timer.Enabled := True;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -