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

📄 jisuanjikongzhi.pas

📁 DELPHI语言制作的音象管理系统 很经典的例子噢 欢迎下载参考
💻 PAS
字号:
unit jisuanjikongzhi;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons;

type
  TForm20 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Label1: TLabel;
    Label2: TLabel;
    RadioGroup1: TRadioGroup;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form20: TForm20;

implementation

{$R *.dfm}

function SetPrivilege(sPrivilegeName : string;bEnabled : boolean ): boolean;
var
  TPPrev,TP : TTokenPrivileges;
  Token : THandle;
  dwRetLen : DWord;
begin
  Result := False;
  OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or 

TOKEN_QUERY,Token);
  TP.PrivilegeCount:=1;
  if( LookupPrivilegeValue(Nil,PChar( sPrivilegeName ),TP.Privileges[ 0 ].LUID ))then
  begin
    if( bEnabled )then //Give this privileges
    begin
      TP.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;
    end
    else begin //NOT Give this privileges
      TP.Privileges[ 0 ].Attributes := 0;
    end;
    dwRetLen := 0;
    //enables or disables privileges in the specified access token.
    Result := AdjustTokenPrivileges(Token,False,TP,SizeOf( TPPrev ),TPPrev,dwRetLen);
  end;
  CloseHandle( Token );
end;

//NT关机函数
function WinExitInNT( iFlags : integer ) : boolean;
begin
  Result := True;
  if( SetPrivilege( 'SeShutdownPrivilege',True ) )then
  begin
    if( not ExitWindowsEx( iFlags,0 ) )then
    begin
      Result := False;
    end;
    SetPrivilege( 'SeShutdownPrivilege',False )
  end
  else begin
  // handle errors...
  Result := False;
  end;
end;

procedure TForm20.SpeedButton1Click(Sender: TObject);
begin
case radiogroup1.itemindex of
0: win32check(exitwindows(0,0));
1: begin
   if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
        ExitWindowsEx(EWX_FORCE+EWX_SHUTDOWN+EWX_POWEROFF,32);
   if win32platform =ver_platform_win32_NT then
   WinExitInNT(EWX_FORCE+EWX_reboot);
   end;
2: begin
   if win32platform =ver_platform_win32_windows then
   exitwindowsex(ewx_force+ewx_shutdown+ewx_poweroff,32);
   if win32platform =ver_platform_win32_NT then
   WinExitInNT(EWX_FORCE+EWX_SHUTDOWN+EWX_POWEROFF);
   end ;
3: win32check(exitwindowsex(ewx_logoff,0));
end;
end;

procedure TForm20.SpeedButton2Click(Sender: TObject);
begin
form20.close;
end;

end.

⌨️ 快捷键说明

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