p_cxthread.pas

来自「这个是我自己写的」· PAS 代码 · 共 89 行

PAS
89
字号
unit p_cxThread;

interface

uses
  Classes;

type
  cxThread = class(TThread)
  private
    { Private declarations }
  public

  protected
    procedure Execute; override;
  end;


  var
    cxName:String;

implementation

uses p_Server,DB,SysUtils,Forms,Windows;

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure cxThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ cxThread }




Function cxUpdate(MyName:String):Boolean;
var
  cxFile:TFileStream;
  cxSize:Single;
  gcts:String;
begin
  Result := False;
  cxFile := TFileStream.Create(cxName,fmOpenRead);
  cxSize := cxFile.Size;
  with frm_Server.sp_in_cxInfo do
  begin
    Close;
    Parameters.ParamByName('@cxName').Value := frm_Server.cb_FileName.Text;
    Parameters.ParamByName('@cxStream').LoadFromStream(cxFile,ftBlob);
    Parameters.ParamByName('@cxVersion').Value := strtoint(frm_Server.Edit2.Text);
    Parameters.ParamByName('@cxNO').Value := strtoint(frm_Server.ed_cxNO.Text);
    Parameters.ParamByName('@cxSize').Value := cxSize;
    //= '程序正在上传.....';
    ExecProc;
    gcts:=Parameters.ParamByName('@gcts').Value;
    if Parameters.ParamByName('@cgbz').Value = 2 then
    begin
      cxFile.Free;
      Result := False;
      Exit;
    end;
    cxFile.Free;
  end;
  Result := True;
end;


procedure cxThread.Execute;
begin
  if cxUpdate(cxName) then
  begin
    Application.MessageBox('保存成功!','提示',0+48);
    bz:=1;
  end else
  begin
    Application.MessageBox('保存失败!','提示',0+16);
    bz:=2;
  end;
end;

end.

⌨️ 快捷键说明

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