delphi.net开发学习笔记(1),状态变量处理(Global.asax)

 

对于Application和SSession状态以及变量的处理可以在这个文件中处理,工程建立时没有这个文件可以从other里面添加;VS2005里面还有对于页面状态变量的处理,这里好像没有,不知道怎么搞,以后研究着看吧。


procedure Application_BeginRequest(sender: System.Object; e: EventArgs);
procedure Application_EndRequest(sender: System.Object; e: EventArgs);
这两个东东看上去很好玩啊!

 

unit Global;

interface

uses
  System.Collections, System.ComponentModel,
  System.Web, System.Web.SessionState;

type
  TGlobal = class(System.Web.HttpApplication)
  {$REGION ‘Designer Managed Code‘}
  strict private
    procedure InitializeComponent;
  {$ENDREGION}
  strict protected
    procedure Application_Start(sender: System.Object; e: EventArgs);
    procedure Session_Start(sender: System.Object; e: EventArgs);
    procedure Application_BeginRequest(sender: System.Object; e: EventArgs);
    procedure Application_EndRequest(sender: System.Object; e: EventArgs);
    procedure Application_AuthenticateRequest(sender: System.Object; e: EventArgs);
    procedure Application_Error(sender: System.Object; e: EventArgs);
    procedure Session_End(sender: System.Object; e: EventArgs);
    procedure Application_End(sender: System.Object; e: EventArgs);
  private
    { Private Declarations }
  public
    constructor Create;
  end;

implementation

{$REGION ‘Designer Managed Code‘}
/// 
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// 
procedure TGlobal.InitializeComponent;
begin

end;
{$ENDREGION}

constructor TGlobal.Create;
begin
  inherited;
  //
  // Required for Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TGlobal.Application_Start(sender: System.Object; e: EventArgs);
begin

end;

procedure TGlobal.Session_Start(sender: System.Object; e: EventArgs);
begin
  Application.Lock;
  try
    if Application[‘NumUsers‘] = nil then
      Application[‘NumUsers‘] := System.Object(Integer(1))
    else
      Application[‘NumUsers‘] :=
        System.Object(Integer(Application[‘NumUsers‘])+1);
  finally
    Application.UnLock;
  end;
end;

procedure TGlobal.Application_BeginRequest(sender: System.Object; e: EventArgs);
begin

end;

procedure TGlobal.Application_EndRequest(sender: System.Object; e: EventArgs);
begin

end;

procedure TGlobal.Application_AuthenticateRequest(sender: System.Object; e: EventArgs);
begin

end;

procedure TGlobal.Application_Error(sender: System.Object; e: EventArgs);
begin

end;

procedure TGlobal.Session_End(sender: System.Object; e: EventArgs);
begin
  Application.Lock;
  try
    if Application[‘NumUsers‘] <> nil then
      Application[‘NumUsers‘] :=
        System.Object(Integer(Application[‘NumUsers‘])-1)
   else
      Application[‘NumUsers‘] := System.Object(Integer(0));
  finally
    Application.UnLock;
  end;
end;

procedure TGlobal.Application_End(sender: System.Object; e: EventArgs);
begin

end;

end.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值