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

📄 p_client.pas

📁 这个是我自己写的
💻 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 ='人事科招聘人员工资管理系统           成都万全数据有限公司';

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 + -