code for shutting down windows

J

Jesper

Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down windows.
--
 
C

Corey Murtagh

Jesper said:
Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down windows.

The C++ language has no concept of "shutting down windows". Your
question is off topic for this newsgroup. You should ask questions like
this in a newsgroup which deals with Windows.

However, since I do actually know the answer:

ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCEIFHUNG, -1);

Or if you want the system logs on WinXP to show something meaningful:

ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OTHER |
SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED);
 
J

Jesper

Thanks for the helt.

About "Off topic": The c++ language has no concept of planets and gravity
either. Still I can make a program usinc c++ that simulates a system of
planets, just like I can now make a program that shuts down windows. So no,
I don't think it's off topic!!!
 
J

Jason

int RebootWindows()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &hToken));
LookupPrivilegeValue(NULL, "SeShutdownPrivilege",
&tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;


AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);

ExitWindowsEx(EWX_REBOOT, 0);

/*
EWX_FORCE, EWX_REBOOT, EWX_POWEROFF, EWX_LOGOFF, EWX_SHUTDOWN
*/


return 0;
}
 
T

Thomas Matthews

Jesper said:
Thanks for the helt.

About "Off topic": The c++ language has no concept of planets and gravity
either. Still I can make a program usinc c++ that simulates a system of
planets, just like I can now make a program that shuts down windows. So no,
I don't think it's off topic!!!

The problem is that I tried using the functions that were cited on my
embedded tapedrive system and the compiler complained. Where in the
_standard_ C++ library are these functions?

How can I shutdown the tapedrive by using these functions?
How does it handle the motors?

How can I turn off the laser printer by using these functions?

Hmmm. I guess your topic isn't about _standard_ C++ but about
a platform specific implementation.

I can model a universe on any platform that supports _standard_
C++ as long as I don't use any platform specific code. Discussion
of the functions would be on topic. However, discussion of
functionality that doesn't run on every platform is off-topic.

If I have a home control (embedded) system that has the ability
to open windows to control the indoor temperature and only an
LED display, can it run windows? Is it a Windows platform?

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
A

Alexander Terekhov

Thomas Matthews wrote:
[...]
If I have a home control (embedded) system that has the ability
to open windows to control the indoor temperature and only an
LED display, can it run windows? Is it a Windows platform?

I see that Matthews is clearly still trying to find a loophole... in
order to "bypass a prison". Oh boy. Give it up, Matthews. Don't waste
time, really. http://google.com/[email protected]

Yes, it IS a Windows platform. Undoubtedly. What else?!

http://www.microsoft.com/windows/Embedded/ce.NET/evaluation/choose/default.asp

http://www.microsoft.com/windows/Embedded/xp/evaluation/faq/default.asp

<quote>

Q. Why should I use Windows XP Embedded and not Linux?

A. Windows XP Embedded is the componentized version of the leading
desktop operating system, enabling original equipment
manufacturers (OEMs) to rapidly develop the most reliable and
full-featured connected devices. ....

</quote>

regards,
alexander.
 
T

Thomas Matthews

Alexander said:
Thomas Matthews wrote:
[...]
If I have a home control (embedded) system that has the ability
to open windows to control the indoor temperature and only an
LED display, can it run windows? Is it a Windows platform?


I see that Matthews is clearly still trying to find a loophole... in
order to "bypass a prison". Oh boy. Give it up, Matthews. Don't waste
time, really. http://google.com/[email protected]

Yes, it IS a Windows platform. Undoubtedly. What else?!

http://www.microsoft.com/windows/Embedded/ce.NET/evaluation/choose/default.asp

http://www.microsoft.com/windows/Embedded/xp/evaluation/faq/default.asp

<quote>

Q. Why should I use Windows XP Embedded and not Linux?

A. Windows XP Embedded is the componentized version of the leading
desktop operating system, enabling original equipment
manufacturers (OEMs) to rapidly develop the most reliable and
full-featured connected devices. ....

</quote>

regards,
alexander.

And Terekhov is still trying to state that Windows is the only
or should be the only platform.
http://groups.google.com/groups?hl=...=Google+Search&meta=group=comp.lang.c%2B%2B.*

Windows and Linux are not the only platforms:
http://www.mentor.com/nucleus/nuc_plus.html
http://www.mentor.com/vrtxos/
http://www.redhat.com/
http://www.qnx.com/
http://www.windriver.com/
http://sources.redhat.com/ecos/
http://www.rtxc.com/

Ask software developers who develop using a Unix or Linux system
how many times they have to reboot their computer and how long
ago was the last time they did.

Ask software developers who develop using Windows NT or Windows
2000 system how many times they have to reboot their computer
and how long ago was the last time they did.

Ask people developing critical embedded systems which operating
systems they use.

FYI, I shutdown (and restarted) my Windows98 PC, and received
the blue screen of death. What kind of operating system has
problems shutting down? Hmmmmm.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top