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

📄 isafer_main.pas

📁 一款防火墙源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     // 肺弊沤祸 辆丰
     {
     if bFWStart then begin
          if OS.dwPlatformId = VER_PLATFORM_WIN32_NT then begin
               iShieldUnit_NT.iShieldSetLogCallback(nil);
               iShieldUnit_NT.iShieldUnInitDriver;
          end else if Form_Main.Setup_9x then begin
               iShieldUnit_95.iShieldSetLogCallback(nil);
               iShieldUnit_95.iShieldUnInitDriver;
          end;
     end;
     }
     //Unitial FW huynote
     // Tray Icon 角青 辆丰窍扁
     TrayIcon.Active:= False;
end;

procedure TForm_Main.TrayIconClick(Sender: TObject);
begin
     Tray_OpenClick(self);
end;

procedure TForm_Main.TrayIconDblClick(Sender: TObject);
begin
     Tray_OpenClick(self);
end;

procedure TForm_Main.Tray_OpenClick(Sender: TObject);
begin
     // Application 焊咯林扁
     if (not IsWindowVisible(Form_Main.Handle)) then begin
          ShowWindow(Application.Handle,SW_SHOWMINIMIZED);
          ShowWindow(Application.Handle,SW_SHOWNORMAL);
     end;
     SetForegroundWindow(Form_Main.Handle);
     // Tray Icon 角青 辆丰窍扁
     TrayIcon.Active:= False;
end;

procedure TForm_Main.Tray_OptionClick(Sender: TObject);
begin
     Btn_OptionClick(self);
end;

procedure TForm_Main.Tray_CloseClick(Sender: TObject);
begin
     Btn_CloseClick(self);
end;

procedure TForm_Main.Btn_SaferMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Safer 滚瓢 Down
begin
     Stat_Safer:= 2;
     Application.ProcessMessages;
     if bFWStart then begin
          SourceRect:= Rect((2*50)+1, (3*30)+1, (2*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
          DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
          Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     end else begin
          SourceRect:= Rect((2*50)+1, (2*30)+1, (2*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
          DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
          Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     end;
     Application.ProcessMessages;
end;

procedure TForm_Main.Btn_SaferMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);   // Safer 滚瓢 Move
begin
     if (Stat_Safer = 0) then begin
          Stat_Safer:= 1;
          Application.ProcessMessages;
          if bFWStart then begin
               SourceRect:= Rect((1*50)+1, (3*30)+1, (1*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
               DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
               Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          end else begin
               SourceRect:= Rect((1*50)+1, (2*30)+1, (1*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
               DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
               Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          end;
          BtnStatusCheck('Btn_Safer');
          Application.ProcessMessages;
     end;
end;

procedure TForm_Main.Btn_SaferMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Safer 滚瓢 Up
begin
     if (Stat_Safer > 0) then begin
          Stat_Safer:= 0;
          Application.ProcessMessages;
          if bFWStart then begin
               SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
               DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
               Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          end else begin
               SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
               DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
               Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          end;
          Application.ProcessMessages;
     end;
end;
//Start FirWall
procedure TForm_Main.Btn_SaferClick(Sender: TObject);       // Safer 滚瓢 Click
begin

     Stat_Safer:= 0;
     Application.ProcessMessages;
     if bFWStart then begin
          SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
          DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
          Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     end else begin
          SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
          DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
          Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     end;
     Application.ProcessMessages;


          {Started Already}
          if bFWStart then begin
               if Application.MessageBox('Do you really want to stop the firewall?', 'iSafer', MB_YESNO) = IDYES then begin
                    PSMFW_UnInitActionExecute(nil);
               end;
          end else
          {Start FireWall!!!}
          begin
               PSMFW_InitActionExecute(nil);
          end;
     
end;

procedure TForm_Main.Btn_OptionMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Option 滚瓢 Down
begin
     Stat_Option:= 2;
     Application.ProcessMessages;
     SourceRect:= Rect((2*50)+1, (4*30)+1, (2*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
     DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
     Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     Application.ProcessMessages;
end;

procedure TForm_Main.Btn_OptionMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);   // Option 滚瓢 Move
begin
     if (Stat_Option = 0) then begin
          Stat_Option:= 1;
          Application.ProcessMessages;
          SourceRect:= Rect((1*50)+1, (4*30)+1, (1*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
          DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
          Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          BtnStatusCheck('Btn_Option');
          Application.ProcessMessages;
     end;
end;

procedure TForm_Main.Btn_OptionMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Option 滚瓢 Up
begin
     if (Stat_Option > 0) then begin
          Stat_Option:= 0;
          Application.ProcessMessages;
          SourceRect:= Rect((0*50)+1, (4*30)+1, (0*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
          DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
          Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          Application.ProcessMessages;
     end;
end;

procedure TForm_Main.Btn_OptionClick(Sender: TObject);      // Option 滚瓢 Click
begin

     Stat_Option:= 0;
     Application.ProcessMessages;
     SourceRect:= Rect((0*50)+1, (4*30)+1, (0*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
     DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
     Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     Application.ProcessMessages;

     // Show firewall option dialogs
     Form_Option.Show;
     //For debug
     if(ParamCount>=1) and(ParamStr(1)='debug') then
     begin
          DebugFW.Show;
     end
end;

procedure TForm_Main.Btn_VaccineMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Vaccine 滚瓢 Down
begin
     Stat_Vaccine:= 2;
     Application.ProcessMessages;
     SourceRect:= Rect((2*50)+1, (5*30)+1, (2*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
     DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
     Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     Application.ProcessMessages;
end;

procedure TForm_Main.Btn_VaccineMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);   // Vaccine 滚瓢 Move
begin
     if (Stat_Vaccine = 0) then begin
          Stat_Vaccine:= 1;
          Application.ProcessMessages;
          SourceRect:= Rect((1*50)+1, (5*30)+1, (1*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
          DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
          Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          BtnStatusCheck('Btn_Vaccine');
          Application.ProcessMessages;
     end;
end;

procedure TForm_Main.Btn_VaccineMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Vaccine 滚瓢 Up
begin
     if (Stat_Vaccine > 0) then begin
          Stat_Vaccine:= 0;
          Application.ProcessMessages;
          SourceRect:= Rect((0*50)+1, (5*30)+1, (0*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
          DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
          Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
          Application.ProcessMessages;
     end;
end;

procedure TForm_Main.Btn_VaccineClick(Sender: TObject);     // Vaccine 滚瓢 Click
begin
  Btn_Vaccine.Enabled:=False;
  LockClick(nil);
  Btn_Vaccine.Enabled:=True;

      {
     Stat_Vaccine:= 0;
     Application.ProcessMessages;
     SourceRect:= Rect((0*50)+1, (5*30)+1, (0*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
     DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
     Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
     Application.ProcessMessages;
     Btn_Vaccine.Enabled:=False;
     //20031212: Includes full path
     ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'vSafer.exe'), nil, nil, SW_SHOW);
     Btn_Vaccine.Enabled:=True;
     }
end;

procedure TForm_Main.Btn_MinimizeClick(Sender: TObject);    // 弥家拳 滚瓢 Click
begin
     // Tray Icon 角青窍扁
     TrayIcon.Active:= True;
     // Application 见扁扁
     if(Form_Option.Visible)then
        Form_Option.Close;
     Application.Minimize;
     ShowWindow(Application.Handle,SW_HIDE);
end;

procedure TForm_Main.Btn_CloseClick(Sender: TObject);       // 辆丰 滚瓢 Click
begin
     if Application.MessageBox('Do you really want to exit?', 'iSafer', MB_YESNO) = IDYES then begin
      PSMFW_UnInitActionExecute(nil);
      Halt(0);
     end;
end;

procedure TForm_Main.Image_SkinMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
     // Form 捞悼窍扁
     bMouseDown:= True;
     posX:= X;
     posY:= Y;
end;

procedure TForm_Main.Image_SkinMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var
     tmpX, tmpY: Integer;
begin
     if bMouseDown then begin
          // Form 捞悼窍扁
          tmpX:= Form_Main.Left + (X - posX);
          tmpY:= Form_Main.Top + (Y - posY);
          if tmpX < 0 then tmpX:= 0;
          if tmpX > GetSystemMetrics(SM_CXFULLSCREEN)-Form_Main.Width then tmpX:= GetSystemMetrics(SM_CXFULLSCREEN)-Form_Main.Width;
          if tmpY < 0 then tmpY:= 0;
          if tmpY > GetSystemMetrics(SM_CYFULLSCREEN)+GetSystemMetrics(SM_CYCAPTION)-Form_Main.Height then tmpY:= GetSystemMetrics(SM_CYFULLSCREEN)+GetSystemMetrics(SM_CYCAPTION)-Form_Main.Height;
          Form_Main.Left:= tmpX;
          Form_Main.Top:= tmpY;
     end else begin
          if (Stat_Safer = 1) or (Stat_Option = 1) or (Stat_Vaccine = 1) then begin
               BtnStatusCheck('');
          end;
     end;
end;

procedure TForm_Main.Image_SkinMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
     // Form 捞悼窍扁
     bMouseDown:= False;
end;

procedure TForm_Main.Label_MessageMouseMove(Sender: TObject;Shift: TShiftState; X, Y: Integer);
begin
     if (Stat_Safer = 1) or (Stat_Option = 1) or (Stat_Vaccine = 1) then begin
          BtnStatusCheck('');
     end;
end;






// Add on 10th March, 2004

procedure TForm_Main.Tray_VirusVaccineClick(Sender: TObject);
begin
     ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'vSafer.exe'), nil, nil, SW_SHOW);
end;

//Execuate help utility
procedure TForm_Main.Tray_HelpClick(Sender: TObject);
begin
    ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'iSaferHelp.chm'), nil, nil, SW_SHOW);
end;

procedure TForm_Main.mnuTrayAboutClick(Sender: TObject);
begin
     ISaferAboutDlg.ShowModal();
end;

procedure TForm_Main.LockClick(Sender: TObject);
type
     tLockScrFunc = function(HWND: DWORD): DWord; stdcall;
var
        LockScr: tLockScrFunc;
begin
        {If the ScreenLock DLL is not loaded yet, load it}
        if ScreenLockDLLHandle < 32 then ScreenLockDLLHandle:= LoadLibrary('PSMScrLk.dll');
        if ScreenLockDLLHandle < 32 then ShowMessage('Error loading PSMScrLk.dll!')
        else
        begin
                @LockScr:= GetProcAddress(ScreenLockDLLHandle, 'LockScr');
                if not (@LockScr = nil) then begin
                        LockScr(0);
                end;
                {NOTE!!!: DO NOT CALL FreeLibrary(), we must keep the process in the DLL running!!!}
                {We will call FreeLibrary() when iSafer exits}
                {FreeLibrary(ScreenLockDLLHandle);}
        end;
end;

procedure TForm_Main.ChangePasswordClick(Sender: TObject);
type
     tChangePWFunc = function(): DWord; stdcall;
var
        ChangePW: tChangePWFunc;
begin
        {If the ScreenLock DLL is not loaded yet, load it}
        if ScreenLockDLLHandle < 32 then ScreenLockDLLHandle:= LoadLibrary('PSMScrLk.dll');
        if ScreenLockDLLHandle < 32 then ShowMessage('Error loading PSMScrLk.dll!')
        else
        begin
                @ChangePW:= GetProcAddress(ScreenLockDLLHandle, 'ChangePW');
                if not (@ChangePW = nil) then begin
                        ChangePW();
                end;
                {NOTE!!!: DO NOT CALL FreeLibrary(), we must keep the process in the DLL running!!!}
                {We will call FreeLibrary() when iSafer exits}
                {FreeLibrary(ScreenLockDLLHandle);}
        end;
end;

end.

⌨️ 快捷键说明

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