linkedin facebook linkedin facebook nod32

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.

1824 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений