Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Shutdown windows

Posted on 1998-12-10
2
Medium Priority
?
220 Views
Last Modified: 2012-05-04
How do I force windows to shutdown / reboot?
0
Comment
Question by:qwertyx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1350290
hi qwertyx,

look at this free component with source

http://www.torry.webnorth.com/vcl/system/wreboot.zip

meikl
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 90 total points
ID: 1350291
see http://www.chami.com/tips/delphi/120996D.html or write the following code:

Var
 PreviosPrivileges: ^TTokenPrivileges;
 TokenPrivileges: TTokenPrivileges;
 ProcessHandle: THandle;
 tmp: Integer;
begin
if not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,ProcessHandle)   then Exit;
   LookupPrivilegeValue('', 'SeShutdownPrivilege', TokenPrivileges.Privileges[0].Luid);
   TokenPrivileges.PrivilegeCount:=1;
   TokenPrivileges.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED;
   tmp:=0;
   PreviosPrivileges:=nil;
   AdjustTokenPrivileges(ProcessHandle, False, TokenPrivileges, 0,    PreviosPrivileges^ ,tmp);
   if not GetLastError()=ERROR_SUCCESS then Exit;
   if not InitiateSystemShutdown('', '', 0, True, True) then Exit;
   TokenPrivileges.Privileges[0].Attributes:=0;
   AdjustTokenPrivileges(ProcessHandle, False, TokenPrivileges,    0,PreviosPrivileges^ ,tmp);
End;
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question