C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

code for shutting down windows

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Jesper
Guest





PostPosted: Sat Jun 28, 2003 8:02 pm    Post subject: code for shutting down windows Reply with quote



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




Back to top
Patrick Kowalzick
Guest





PostPosted: Sat Jun 28, 2003 8:18 pm    Post subject: Re: code for shutting down windows Reply with quote



Is there some code to shut it down forever ?

Patrick

"Jesper" <jesper (AT) i-dont-want-spam (DOT) oek.dk> schrieb im Newsbeitrag
news:bdks63$dcl$1 (AT) news (DOT) net.uni-c.dk...
Quote:
Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down windows.
--







Back to top
Corey Murtagh
Guest





PostPosted: Sat Jun 28, 2003 8:36 pm    Post subject: Re: [OT] code for shutting down windows Reply with quote



Jesper wrote:
Quote:
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);

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"


Back to top
Jonathan Clements
Guest





PostPosted: Sun Jun 29, 2003 6:04 pm    Post subject: Re: code for shutting down windows Reply with quote

We can only hope... (I'm stuck with it though!)

"Patrick Kowalzick" <patrick.kowalzick (AT) web (DOT) de> wrote

Quote:
Is there some code to shut it down forever ?

Patrick

"Jesper" <jesper (AT) i-dont-want-spam (DOT) oek.dk> schrieb im Newsbeitrag
news:bdks63$dcl$1 (AT) news (DOT) net.uni-c.dk...
Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down
windows.
--









Back to top
Dhruv
Guest





PostPosted: Sun Jun 29, 2003 6:57 pm    Post subject: Re: code for shutting down windows Reply with quote

On Sun, 29 Jun 2003 19:04:41 +0100, Jonathan Clements wrote:

Quote:
We can only hope... (I'm stuck with it though!)

"Patrick Kowalzick" <patrick.kowalzick (AT) web (DOT) de> wrote in message
news:3efdf67c$0$11671$626a54ce (AT) news (DOT) free.fr...
Yes, I've already got it. It's called GNU/Linux.

And what's better, you don't need Windows to run it!!!

Dhruv.

Quote:
Is there some code to shut it down forever ?

Patrick

"Jesper" <jesper (AT) i-dont-want-spam (DOT) oek.dk> schrieb im Newsbeitrag
news:bdks63$dcl$1 (AT) news (DOT) net.uni-c.dk...
Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down
windows.
--








Back to top
Jesper
Guest





PostPosted: Mon Jun 30, 2003 11:23 am    Post subject: Re: [OT] code for shutting down windows Reply with quote

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!!!


--
Mvh. Jesper


"Corey Murtagh" <emonk (AT) slingshot (DOT) co.nz.no.uce> wrote

Quote:
Jesper wrote:
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);

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"




Back to top
Jason
Guest





PostPosted: Wed Jul 02, 2003 3:39 am    Post subject: Re: code for shutting down windows Reply with quote

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;
}
Back to top
Thomas Matthews
Guest





PostPosted: Wed Jul 02, 2003 4:36 pm    Post subject: Re: [OT] code for shutting down windows Reply with quote

Jesper wrote:
Quote:
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


Back to top
Alexander Terekhov
Guest





PostPosted: Wed Jul 02, 2003 5:29 pm    Post subject: Re: [OT] code for shutting down windows Reply with quote


Thomas Matthews wrote:
[...]
Quote:
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/groups?selm=3EFC57C6.8BC34616%40web.de

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.

Back to top
Thomas Matthews
Guest





PostPosted: Wed Jul 02, 2003 7:49 pm    Post subject: Re: [OT] code for shutting down windows Reply with quote

Alexander Terekhov wrote:
Quote:
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/groups?selm=3EFC57C6.8BC34616%40web.de

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.
[url]http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=Terekhov+windows&btnG=Google+Search&meta=group%3Dcomp.lang.c%252B%252B.*[/url]

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


Back to top
D. Rush
Guest





PostPosted: Wed Sep 29, 2004 10:57 pm    Post subject: Re: code for shutting down windows Reply with quote

Another example that will reboot windows for you:
http://www.koders.com/cpp/fid48127C9E8CC5EFA843B3C780BD76BD6C3BA2A12C.aspx?s=reboot+windows


"Jesper" <jesper (AT) i-dont-want-spam (DOT) oek.dk> wrote

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







Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.