delphi7强制关机
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
八仙饭店之人肉叉烧包筷子插那一段是真的吗
    { Public declarations }
  end;
    function GetOperatingSystem(): string;
    procedure ShutDownComputer();10级伤残
    procedure Get_Shutdown_Privilege();
var
u盘东西删不掉  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShutDownComputer();
end;
procedure ShutDownComputer();
begin
  if GetOperatingSystem() = 'Windows NT/2000/XP' then
  begin
    Get_Shutdown_Privilege();
    //调用此函数会出现系统关机提示窗口,并允许用户取消关机动作
    InitiateSystemShutDown(nil, '关机提示:讨厌你所以关了你!', 3, True, False);
    // InitiateSystemShutDown去掉的话就不显示提示窗口
    ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE+EWX_POWEROFF+EWX_FORCEIFHUNG,0);
  end
  else
  begin
    ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE+EWX_POWEROFF+EWX_FORCEIFHUNG,0);
  end;
end;
function GetOperatingSystem(): string; //获取操作系统信息
var
  osVerInfo: TOSVersionInfo;
begin
  Result:= '';
  osVerInfo.dwOSVersionInfoSize:= SizeOf(TOSVersionInfo);
农村医疗保险
  if GetVersionEx(osVerInfo) then
    case osVerInfo.dwPlatformId of
    VER_PLATFORM_WIN32_NT:
      begin
        Result:= 'Windows NT/2000/XP'
      end;
    VER_PLATFORM_WIN32_WINDOWS:
      begin
        Result := 'Windows 95/98/98SE/Me';
      end;
  end;
end;吾将上下而求索的上一句
番茄炒蛋怎么做
procedure Get_Shutdown_Privilege(); //获得用户关机特权,仅对Windows NT/2000/XP
var 
  rl: Cardinal; 
  hToken: Cardinal; 
  tkp: TOKEN_PRIVILEGES; 
begin
  OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
  if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then
  begin 
    tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED;
    tkp.PrivilegeCount:= 1;
    AdjustTokenPrivileges(hToken, False, tkp, 0, nil, rl); 
  end; 
end;
end.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。