Muallif: Mengliyev Sh


Download 24.28 Kb.
Sana26.10.2020
Hajmi24.28 Kb.
#137043
Bog'liq
Delphi da kompyuterni o


Delphi da kompyuterni o'chirish usuli

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2014-10-28

Delphi dasturlash tilida kompyuterni o'chirish usuli


Quyida Formaning dizayni delphi da yaratib olinadi



Dastur kodi

unit Unit1;

interface

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

type
TForm1 = class(TForm)


BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
procedure Shutdown(Flags: DWORD);
var
hToken: THandle;
Luid: Int64;
NewPrivileges: TTokenPrivileges;
OldPrivileges: TTokenPrivileges;
OldPrivilegesSize: DWORD;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Win32Check(LookupPrivilegeValue(nil,
'SeShutdownPrivilege', Luid));
Win32Check(OpenProcessToken(GetCurrentProcess,
TOKEN_ADJUST_PRIVILEGES or
TOKEN_QUERY, hToken));
NewPrivileges.PrivilegeCount := 1;
NewPrivileges.Privileges[0].Attributes :=
SE_PRIVILEGE_ENABLED;
NewPrivileges.Privileges[0].Luid := Luid;
AdjustTokenPrivileges(hToken, False,
NewPrivileges, SizeOf(OldPrivileges),
OldPrivileges, OldPrivilegesSize);
try
Win32Check(GetLastError = ERROR_SUCCESS);
finally
CloseHandle(hToken);
end
end;
Win32Check(ExitWindowsEx(Flags, 0));
end;

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Shutdown(EWX_SHUTDOWN );
end;

procedure TForm1.BitBtn2Click(Sender: TObject);


begin
Shutdown(EWX_REBOOT);
end;

procedure TForm1.BitBtn3Click(Sender: TObject);


begin
Shutdown(EWX_LOGOFF);
end;

end.
Download 24.28 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling