Soyez le premier à donner votre avis sur cette source.
Vue 7 429 fois - Téléchargée 549 fois
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; implementation uses Uboot; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin if IsWinNT then ShowMessage('OK') else ShowMessage('Pas OK'); end; procedure TForm1.Button2Click(Sender: TObject); begin ShutDownNT(true); end; procedure TForm1.Button3Click(Sender: TObject); begin PowerDownNT(true); end; procedure TForm1.Button4Click(Sender: TObject); begin RebootNT(true); end; procedure TForm1.Button5Click(Sender: TObject); begin LogOffNT(true); end; procedure TForm1.Button6Click(Sender: TObject); begin close; end; procedure TForm1.Button7Click(Sender: TObject); begin MiseEnVeillePC(True, True); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Application.Terminate; end; end. //==================================================== unit Uboot; interface uses Windows, Dialogs; Function IsWinNT : Boolean; Procedure EnableShutDown; Procedure ShutDownNT (Force : Bool); Procedure PowerDownNT (Force : Bool); Procedure RebootNT (Force : Bool); Procedure LogOffNT (Force : Bool); Procedure MiseEnVeillePC(fSuspend, fForce : bool); implementation Function IsWinNT : Boolean; var myOS: TOSVersionInfo; begin myOS.dwOSVersionInfoSize := Sizeof(myOS); GetVersionEx(myOS); result := (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT); end; procedure EnableShutDown; var mPriv,mNewPriv : TTokenPrivileges; ReturnLen : DWORD ; hProc,hToken : THANDLE ; mLUID : TLargeInteger ; begin hProc := GetCurrentProcess ; OpenProcessToken (hProc,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken); LookupPrivilegeValue(nil,'SeShutdownPrivilege',mLUID); mPriv.PrivilegeCount := 1; mPriv.Privileges[0].Luid := mLUID; mPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken,FALSE,mPriv,sizeof(TTokenPrivileges),mNewPriv,ReturnLen); CloseHandle (hToken); end; //fonction qui éteint le PC (Force=true oblige le traitement) Procedure ShutDownNT (Force : Bool); var ret: bool; FLAGS : Integer; begin FLAGS := EWX_SHUTDOWN; If Force Then FLAGS := FLAGS or EWX_FORCE; If IsWinNT Then EnableShutDown; ret := ExitWindowsEx (FLAGS, 0); If ret = False then ShowMessage ('Impossible de fermer Windows'); end; //fonction qui éteint totalement la tour (Force=true oblige le traitement) Procedure PowerDownNT (Force : Bool); var ret: bool; FLAGS : Integer; begin FLAGS := EWX_POWEROFF; If Force Then FLAGS := FLAGS or EWX_FORCE; If IsWinNT Then EnableShutDown; ret := ExitWindowsEx (FLAGS, 0); If ret = False then ShowMessage ('Impossible de fermer Windows'); end; // fonction qui fait rebooter l'OS (Force=true oblige le traitement) Procedure RebootNT (Force : Bool); var ret: bool; FLAGS : Integer; begin FLAGS := EWX_REBOOT; If Force Then FLAGS := FLAGS or EWX_FORCE; If IsWinNT Then EnableShutDown; ret := ExitWindowsEx (FLAGS, 0); If ret = False then ShowMessage ('Impossible de fermer Windows'); end; //fonction qui délogue l'user (Force=true oblige le traitement) Procedure LogOffNT (Force : Bool); var ret: bool; FLAGS : Integer; begin FLAGS := EWX_LOGOFF; If Force Then FLAGS := FLAGS or EWX_FORCE; If IsWinNT Then EnableShutDown; ret := ExitWindowsEx (FLAGS, 0); If ret = False then ShowMessage ('Impossible de fermer Windows'); end; //Procédure de mise en veille du PC Procedure MiseEnVeillePC(fSuspend, fForce : bool); var succes : bool; begin If IsWinNT Then EnableShutDown; succes := SetSystemPowerState(fSuspend, fForce); if not succes then showmessage ('Impossible de mettre le PC en veille'); end; end.
10 oct. 2003 à 10:15
sert à verrouiller le poste rapidement SOUS WINDOWS NT 4 un peu comme LOCKWORKSTATION pour WINDOWS XP (Exemple sur ce site)
Je ne sais pas utiliser cette fonction et je n'ai pas trouver de commentaires sur celle ci sur aucun site
Si des fois vous aviez une idée ça m'interesse car je cherche a verrouiller rapidement mon poste au boulot sous windows NT 4
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.