ورود

View Full Version : سورس برنامه ی کنترل کننده ی سیستم



Delphi Skyline
سه شنبه 13 بهمن 1383, 20:02 عصر
کاربرد این برنامه:
مثلا شما می خواهید 1 ساعت دیگر کامپیوتر خاموش شود.


---------
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button3: TButton;
Timer1: TTimer;
Button4: TButton;
Image1: TImage;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function MyExitWindows(RebootParam: Longword): Boolean;
var
TTokenHd: THandle;
TTokenPvg: TTokenPrivileges;
cbtpPrevious: DWORD;
rTTokenPvg: TTokenPrivileges;
pcbtpPreviousRequired: DWORD;
tpResult: Boolean;
const
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tpResult := OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
TTokenHd);
if tpResult then
begin
tpResult := LookupPrivilegeValue(nil,
SE_SHUTDOWN_NAME,
TTokenPvg.Privileges[0].Luid);
TTokenPvg.PrivilegeCount := 1;
TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
cbtpPrevious := SizeOf(rTTokenPvg);
pcbtpPreviousRequired := 0;
if tpResult then
Windows.AdjustTokenPrivileges(TTokenHd,
False,
TTokenPvg,
cbtpPrevious,
rTTokenPvg,
pcbtpPreviousRequired);
end;
end;
Result := ExitWindowsEx(RebootParam, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
var a:ttime;i:integer;s:string;j:string;
begin
a:=time;
j:=timetostr(a);
i:=length(j);
s:=copy(j,0,i-4);
edit1.Text:=s;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var a:ttime;s,j:string;i:integer;
begin
a:=time;
j:=timetostr(a);
i:=length(j);
s:=copy(j,0,i-4);
if s=edit1.Text then
begin
if radiobutton1.Checked then
MyExitWindows(EWX_POWEROFF or EWX_FORCE);
if radiobutton2.Checked then
MyExitWindows(EWX_REBOOT or EWX_FORCE);
if radiobutton3.Checked then
MyExitWindows( EWX_LOGOFF or EWX_FORCE );

end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var a:tcanvas;
begin
a:=tcanvas.Create;
a.Handle:=getwindowdc(0);
shellexecute(form1.Handle,'open',pchar('E:\Program Files\Ahead\Nero StartSmart\NeroStartSmart.exe'),'','',sw_show);
{button1.Enabled:=false;
edit1.Enabled:=false;
timer1.Enabled:=true; }
end;

procedure TForm1.Button4Click(Sender: TObject);
begin

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
application.Title:='SC 2005';
end;

end.

--------------
لذت ببرید... :oops: :)

esi022
سه شنبه 13 بهمن 1383, 23:16 عصر
Delphi Skyline سلام
لطفا سورسهای زیاد رو فایل کن و اینکه سورسها رو بصورت code نشون بده

Mahdi-563
سه شنبه 20 بهمن 1383, 15:48 عصر
سلام دست درد نکنه :flower: :flower:

اطفاقا تو فکرش بودم :تشویق:

راحتم کردی :flower: :flower: :flower:

فرزاد دلفی باز
شنبه 24 بهمن 1383, 10:58 صبح
دوست عزیز Delphi Skyline :
جالب بود متشکر ....