?
Solved

HOW TURN OFF WINDOWS XP

Posted on 2004-04-18
5
Medium Priority
?
487 Views
Last Modified: 2010-04-05
hi
if i want turn off system with code of my delphi
in windows xp i con not run this statement  ExitWindowsex
i just log off
tank you for next help

0
Comment
Question by:HOSIN_SHAFIEI
[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
5 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10857386
have you tried  ExitWindowsEx(EWX_POWEROFF ,0);  ?

from microsoft;
******************************
uFlags
     One or more of the following flags specifying how to shut down or reboot the computer:
     EWX_FORCE = 4
          Force any applications to quit instead of prompting the user to close them.
     EWX_LOGOFF = 0
          Log off the network.
     EWX_POWEROFF = 8
          Shut down the system and, if possible, turn the computer off.
     EWX_REBOOT = 2
          Perform a full reboot of the system.
     EWX_SHUTDOWN = 1
          Shut down the system.
dwReserved
     Reserved for future versions of Windows. Always set to 0.
******************************

0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10857394
BTW If it don't work anymore look at this Madshi PAQ that have explained and solved this matter on XP Systems...

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20268837.html
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10857616
Try this

function ExitWindows(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;


//And call it like this

procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindows(EWX_POWEROFF or EWX_SHUTDOWN);
end;
0
 

Accepted Solution

by:
lopardo2003 earned 200 total points
ID: 10865151
Check this demo about how to shutdown / restart / hibernate / standby / log off / turn off screen in any Windows version:
http://360software.dakotabcn.net/files/systemactions.zip
0
 

Author Comment

by:HOSIN_SHAFIEI
ID: 10866434
hi
 thank of all teachers
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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