473,765 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code for shutting down windows

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


Jul 19 '05 #1
10 18653
Is there some code to shut it down forever ?

Patrick

"Jesper" <je****@i-dont-want-spam.oek.dk> schrieb im Newsbeitrag
news:bd******** **@news.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.
--

Jul 19 '05 #2
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(E WX_SHUTDOWN | EWX_FORCEIFHUNG , -1);

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

ExitWindowsEx(E WX_SHUTDOWN | EWX_FORCEIFHUNG , SHTDN_REASON_MA JOR_OTHER |
SHTDN_REASON_MI NOR_OTHER | SHTDN_REASON_FL AG_PLANNED);

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

Jul 19 '05 #3
We can only hope... (I'm stuck with it though!)

"Patrick Kowalzick" <pa************ ***@web.de> wrote in message
news:3e******** *************** @news.free.fr.. .
Is there some code to shut it down forever ?

Patrick

"Jesper" <je****@i-dont-want-spam.oek.dk> schrieb im Newsbeitrag
news:bd******** **@news.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. --


Jul 19 '05 #4
On Sun, 29 Jun 2003 19:04:41 +0100, Jonathan Clements wrote:
We can only hope... (I'm stuck with it though!)

"Patrick Kowalzick" <pa************ ***@web.de> wrote in message
news:3e******** *************** @news.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.
Is there some code to shut it down forever ?

Patrick

"Jesper" <je****@i-dont-want-spam.oek.dk> schrieb im Newsbeitrag
news:bd******** **@news.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. > --
>
>
>
>



Jul 19 '05 #5
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" <em***@slingsho t.co.nz.no.uce> wrote in message
news:10******** *******@radsrv1 .tranzpeer.net. ..
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(E WX_SHUTDOWN | EWX_FORCEIFHUNG , -1);

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

ExitWindowsEx(E WX_SHUTDOWN | EWX_FORCEIFHUNG , SHTDN_REASON_MA JOR_OTHER |
SHTDN_REASON_MI NOR_OTHER | SHTDN_REASON_FL AG_PLANNED);

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

Jul 19 '05 #6
int RebootWindows()
{
HANDLE hToken;
TOKEN_PRIVILEGE S tkp;

(!OpenProcessTo ken(GetCurrentP rocess(), TOKEN_ADJUST_PR IVILEGES |
TOKEN_QUERY, &hToken));
LookupPrivilege Value(NULL, "SeShutdownPriv ilege",
&tkp.Privile ges[0].Luid);

tkp.PrivilegeCo unt = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_EN ABLED;
AdjustTokenPriv ileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILE GES)NULL, 0);

ExitWindowsEx(E WX_REBOOT, 0);

/*
EWX_FORCE, EWX_REBOOT, EWX_POWEROFF, EWX_LOGOFF, EWX_SHUTDOWN
*/
return 0;
}
Jul 19 '05 #7
Jesper wrote:
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.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #8

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=3EFC57...34616%40web.de

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

http://www.microsoft.com/windows/Emb...se/default.asp

http://www.microsoft.com/windows/Emb...aq/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.
Jul 19 '05 #9
Alexander Terekhov wrote:
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=3EFC57...34616%40web.de

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

http://www.microsoft.com/windows/Emb...se/default.asp

http://www.microsoft.com/windows/Emb...aq/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=e....c%252B%252B.*

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.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2703
by: EW | last post by:
I have a problem when using the python script found here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 It is a script to remotely shutdown a windows computer. When I use it, the computer shuts down, but doesn't power off like with a regular shutdown. It stays on the "Safe to power off" screen and I have to push the power button to actually power off. Anyone know why this happens with this script? Thanks for any...
1
2065
by: mikelostcause | last post by:
I'm working on shutting down an app that runs in the system tray, I have no problems shutting down, but I have problems saving data first. if the base.WndProc(ref m) is placed at the top, it closes, but the system does not continue to shutdown and it does not save the data via the Logout() funtion. If the base.WndProc(ref m) is placed at the bottom, it closes correctly, but doesn't seem to perform the Logout function. protected...
2
19935
by: Mike Stephens | last post by:
I have an application to minimizes when X is clicked. If the user wants to close the application they click the Exit Application button.This works fine and does exactly what I need. I have since discovered it is holding Windows open when you shutdown. If the application is running and the user shutsdown Window it holds up everything. If the application is not running and the user shutsdown Windows is shutsdown in a timely manner. How...
2
1518
by: Rahul | last post by:
IIS in our server is shutting down automatically on its own. I don't know what is the problem? Please suggest?
3
5132
by: diffuser78 | last post by:
I am a newbie in Python and want your help in writing python script. I have to remotely shut the windows px from linux box. I run OpenSSH on windows PC. I remotely connect it from Linux box using ..... ssh Admin@IP_ADDR # connects me fine now without problems (LOCAL) Next, I wrote a script that would log me in and also shut the windows
4
3408
by: Markus Stoeger | last post by:
Hi, I have a problem with Application.Run() when Windows is shutting down. Please have a look at the copy&paste example program below. The application has no forms. It has only got a notify icon in the system tray and it uses Application.Run() to keep the message loop running. When the user clicks the icon, the application should shut down and exit. So far that works fine.
7
4270
by: Mark | last post by:
It is possible from a .NET application to prevent Windows from shutting down? I understand that a .NET application can "know" that windows is initiating the process of to shutting down - but what about *preventing* that shutdown? (and yes - I know the user can always unplug the machine) Thanks.
0
1325
by: Neil | last post by:
I am trying shut down work stations that are left on over night. This works great when a user is logged in or the machine is locked but fails miserably when no body is using the work station, the programme starts but does not execute. The program below runs ok right down to shut down call then fails, any help will be gratefully received Imports System
2
2019
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I am monitoring web apps with the windows event log and noticed several (Hosting environment is shutting down) statements. The server appears to still be running, just wondering any ideas on what can cause this, thanks. -- Paul G Software engineer.
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.