Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Izvorni kod za Shut down

[es] :: Pascal / Delphi / Kylix :: Izvorni kod za Shut down

[ Pregleda: 2569 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

wargamehide
Sex & Ex
`

Član broj: 17397
Poruke: 51
*.verat.net



Profil

icon Izvorni kod za Shut down17.03.2004. u 17:36 - pre 244 meseci
Imam ovaj kod:



unit AutoShut1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus,SetTime, AppEvnts,shellapi;

type
TForm1 = class(TForm)
Timer1: TTimer;
MainMenu1: TMainMenu;
Setting1: TMenuItem;
imeSet1: TMenuItem;
Exit1: TMenuItem;
ApplicationEvents1: TApplicationEvents;
PopupMenu1: TPopupMenu;
imeSet2: TMenuItem;
Exit2: TMenuItem;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
procedure imeSet1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
// procedure MinimizeToTray(Var Msg:TWMSysCommand);Message WM_SYSCOMMAND;
procedure TrayNot(Var Msg:TMessage); message WM_USER;
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure imeSet2Click(Sender: TObject);
procedure Exit2Click(Sender: TObject);
private
{ Private declarations }
a:NOTIFYICONDATA;
procedure MinimizeIt();
public

{ Public declarations }
end;

var
Form1: TForm1;
P,Ti1:Pchar;
Flags:Longint;

implementation

{$R *.dfm}
{procedure Tform1.MinimizeToTray(Var Msg:TWMSysCommand);
Begin
if (Msg.CmdType=SC_MINIMIZE) then
Begin
MinimizeIt();
End;
inherited;
End;}

procedure Tform1.MinimizeIt;
Begin
a.cbSize:=sizeof(a);
a.Wnd:=Self.Handle;
a.uFlags:=NIF_ICON+NIF_MESSAGE+NIF_TIP;
a.uCallbackMessage:=WM_USER;
a.hIcon:=application.Icon.Handle;
a.szTip:='AutoShutDown';
Shell_NotifyIcon(NIM_ADD,@a);
End;

procedure Tform1.TrayNot(var Msg:TMessage);
var
X,Y:Tpoint;
J,K:Integer;
Begin
GetCursorPos(X);
GetCursorPos(Y);
J:=X.X;
K:=Y.Y;
if Msg.LParam=WM_RBUTTONDOWN then
Begin
PopupMenu1.Popup(J,K);
End;
if Msg.LParam=WM_LBUTTONDOWN then
Begin
ShowWindow(Application.Handle,SW_SHOW);
Application.Restore;
Shell_NotifyIcon(NIM_DELETE,@a);
End;
End;

procedure Shutdown(Force:Boolean);
Begin
if Force Then
Begin
Flags:=EWX_SHUTDOWN+EWX_FORCE;
ExitWindowsEx(Flags,0);
End;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
GetMem(Ti1,25);
Ti1^:=Chr(0);
StrLCat(Ti1,PChar(TimeToStr(Now)),5);
P:=AnsiLastChar(Ti1);
if P= ':' then
Begin
Ti1^:=Chr(0);
StrLCat(Ti1,PChar(TimeToStr(Now)),4);
End;
Edit1.Text:=Ti1;
if Ti1= Form2.Edit1.Text then
Begin
Timer1.Enabled:=False;
Shutdown(True);
End;
end;

procedure TForm1.imeSet1Click(Sender: TObject);
begin
Form2.Visible:=True;
end;

procedure TForm1.Exit1Click(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
Application.Terminate;
end;

procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
MinimizeIt;
ShowWindow(Application.Handle,SW_HIDE);
end;

procedure TForm1.ApplicationEvents1Restore(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
ShowWindow(Application.Handle,SW_NORMAL);
end;

procedure TForm1.imeSet2Click(Sender: TObject);
begin
Form2.Visible:=True;
end;

procedure TForm1.Exit2Click(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
Application.Terminate;
end;

end.




Ali nece da radi prog. Ne prijavljuje nikakvu gresku, jednostavno nece da ugasi komp.

Imate li vi neke kodove?
Objavite ih


maybe baby
baby meybe
 
Odgovor na temu

Dusan Aleksic
Student; web developer @ freelance
Beograd

Član broj: 5244
Poruke: 200
*.ptt.yu

ICQ: 129852450


+5 Profil

icon Re: Izvorni kod za Shut down18.03.2004. u 00:37 - pre 244 meseci
ja ovo koristim za neku proceduru koja treba da ugasi komp.


Code:
procedure blabla;
var
  token:integer;
  luid:int64;
  priv:TTokenPrivileges;
  s:cardinal;
begin
if Win32Platform=VER_PLATFORM_WIN32_NT then begin
openprocesstoken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,cardinal(token));
LookupPrivilegeValue(nil,'SeShutdownPrivilege',luid);
priv.PrivilegeCount:=1;
priv.Privileges[0].Luid:=luid;
priv.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(token,false,priv,0,nil,s);
end;
ExitWindowsEx(EWX_POWEROFF+EWX_FORCE ,0);

end;


sudo make me a sandwich
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Izvorni kod za Shut down

[ Pregleda: 2569 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.