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

📄 unitmain.pas

📁 CMPP3移动短信平台400条/S 稳定版
💻 PAS
字号:
{
  网关主界面,提供系统运行信息,短信流量统计;
  提供定时器。
}
unit UnitMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls, jpeg, UnitSmsRecv, UnitSmsSend,
  KsSkinEngine, se_controls, KsSkinForms;
const ShowRunInfo = wm_User + 111; //自定义显示运行信息消息,在FrmMain处理此消息
const GetCountInfo = wm_User + 112; //自定义获取发送接收短信数量信息消息
type
  TFrmMain = class(TForm)
    StatusBar1: TStatusBar;
    Memo1: TMemo;
    GroupBox1: TGroupBox;
    Image1: TImage;
    ListView1: TListView;
    Timer1: TTimer;
    SeSkinForm1: TSeSkinForm;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Memo1Change(Sender: TObject);
  private
    { Private declarations }
    procedure GetCountInfo(var Msg: TMessage); message GetCountInfo; //GetCountInfo消息处理函数
    procedure ShowRunInfo(var Msg: TMessage); message ShowRunInfo; //Showruninfo消息处理函数
  public
    { Public declarations }
  end;

var
  FrmMain: TFrmMain;
  UiActive: Boolean; //短信接收线程激活标志
  SendActive: Boolean; //短信发送线程激活标志
  tmpsmsui: smsui; //接收短消息线程
  tmpsendsms: unitsendsms; //发送短消息线程
implementation

{$R *.dfm}

procedure TFrmMain.GetCountInfo(var Msg: TMessage); //ListView中添加系统运行信息,主要是发送和接受短信数量
begin
  if (Msg.WParam = 1) and (Msg.LParam = 1) then //发送成功计数
  begin
    ListView1.Items[0].SubItems[0] := IntToStr(StrToInt(ListView1.Items[0].SubItems[0]) + 1);
    ListView1.Items[0].SubItems[2] := IntToStr(StrToInt(ListView1.Items[0].SubItems[2]) + 1);
    exit;
  end;
  if (Msg.WParam = 2) and (Msg.LParam = 2) then //发送失败计数
  begin
    ListView1.Items[0].SubItems[1] := IntToStr(StrToInt(ListView1.Items[0].SubItems[1]) + 1);
    ListView1.Items[0].SubItems[2] := IntToStr(StrToInt(ListView1.Items[0].SubItems[2]) + 1);
    exit;
  end;
  if (Msg.WParam = 0) and (Msg.LParam = 0) then //接收成功计数
  begin
    ListView1.Items[1].SubItems[0] := IntToStr(StrToInt(ListView1.Items[1].SubItems[0]) + 1);
    ListView1.Items[1].SubItems[2] := IntToStr(StrToInt(ListView1.Items[1].SubItems[2]) + 1);
    exit;
  end;
end;

procedure TFrmMain.ShowRunInfo(var Msg: TMessage); //显示运行信息
begin
  Memo1.Lines.Add(PChar(Msg.LParam));
end;

procedure TFrmMain.FormCreate(Sender: TObject);
begin
  StatusBar1.Panels.Items[1].Text := DateTimeToStr(Now); //显示系统运行时间
end;

procedure TFrmMain.Timer1Timer(Sender: TObject);
begin
  if not UiActive then //启动接收短信息线程
  begin
    tmpsmsui := smsui.Create(false);
    Memo1.Lines.Add('重新启动短消息接收线程!');
    UiActive := true;
  end;
  if not SendActive then //启动短消息发送线程
  begin
    tmpSendsms := unitsendsms.Create(false);
    Memo1.Lines.Add('重新启动短消息发送线程!');
    SendActive := true;
  end;
end;

procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  {if messagedlg('您确认要停止短信服务吗?', mtwarning, [mbyes, mbno], 0) = mryes then
  begin
    tmpsmsui.Terminate;
    tmpsendsms.Terminate;
  end
  else
    Action := canone;}
   seskinform1.WindowState:=kwsTray;
   action:=canone;

end;

procedure TFrmMain.Memo1Change(Sender: TObject); //记录程序运行日志
begin
  if Memo1.Lines.Count >= 100 then
  begin
    memo1.Lines.SaveToFile('logRuninfo\' + formatdatetime('yymmddhhnnss', now()) + '.txt');
    Memo1.Lines.Clear;
  end;
end;

end.

⌨️ 快捷键说明

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