473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Restarting windows from c++

CRE
Or more exactly, how does one access the windows API to do things like
shutdowns
?

--chris

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 '05 #1
8 1918
On Thu, 01 Jul 2004 21:57:01 -0800, CRE <l4************@yahoo.com> wrote:
Or more exactly, how does one access the windows API to do things like
shutdowns
?


Your question is about the Windows API, not about C++. Ask in a Windows
programming group, news:comp.os.ms-windows.programmer.win32 for instance.
You are off topic here.

john
Jul 22 '05 #2
"CRE" <l4************@yahoo.com> wrote in message
news:opsahxhb0nxqbskj@datamave-icwjaz...
Or more exactly, how does one access the windows API to do things like
shutdowns
?


One looks in the documentation for a Windows-targeted
implementation, which typically provides the API
reference, or visits www.msdn.microsoft.com, where
the API is documented.

Your query is not topical here.

Purpose of comp.lang.c++:
http://www.slack.net/~shiva/welcome.txt

Locating newsgroups about given topics:
www.groups.google.com
-Mike
Jul 22 '05 #3
CRE posted:
Or more exactly, how does one access the windows API to do things like
shutdowns
?

--chris


#include <windows.h>

int main()
{
ExitWindowsEx(....
}
That's fun. But what's even more fun is getting into the device drivers for
the actual power, ie. electricity, to the computer, and just instantly
turning the computer off.

This if OFF-TOPIC, away with you to msnews.microsoft.com!
-JKOp
Jul 22 '05 #4
int main()
{
ExitWindowsEx(....
}


IMHO W95/W98/ME only.
Win NT,W2k&XP need adjusted Rights.

Rainer
Jul 22 '05 #5
"Rainer Hausbach" <R.********@d-offline.de> wrote in message
news:cc*********@mail1.sbs.de...
int main()
{
ExitWindowsEx(....
}


IMHO W95/W98/ME only.
Win NT,W2k&XP need adjusted Rights.


Actually, this never works, at least not to shut down the system.

As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however use
the code above to log off the current user without additional effort.
And while calling ExitWindowsEx to shut down is ok in Win9x, you can't
actually use it from a Console Application! ^_^

--
Unforgiven

Jul 22 '05 #6
Unforgiven posted:
"Rainer Hausbach" <R.********@d-offline.de> wrote in message
news:cc*********@mail1.sbs.de...
int main()
{
ExitWindowsEx(....
}

IMHO W95/W98/ME only.
Win NT,W2k&XP need adjusted Rights.


Actually, this never works, at least not to shut down the system.

Lies. Shutting down the system was all I ever did when I started out with
Win32 programming.

As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however
use the code above to log off the current user without additional
effort. And while calling ExitWindowsEx to shut down is ok in Win9x,
you can't actually use it from a Console Application! ^_^


Lies. Win32 Console Applications have full access to dynamically linked
libraries, namely the Win32 API.
-JKop
Jul 22 '05 #7
"JKop" <NU**@NULL.NULL> wrote in message
news:CR*****************@news.indigo.ie...
Unforgiven posted:
"Rainer Hausbach" <R.********@d-offline.de> wrote in message
news:cc*********@mail1.sbs.de...
int main()
{
ExitWindowsEx(....
}
IMHO W95/W98/ME only.
Win NT,W2k&XP need adjusted Rights.


Actually, this never works, at least not to shut down the system.

Lies. Shutting down the system was all I ever did when I started out with
Win32 programming.

As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however
use the code above to log off the current user without additional
effort. And while calling ExitWindowsEx to shut down is ok in Win9x,
you can't actually use it from a Console Application! ^_^


Lies. Win32 Console Applications have full access to dynamically linked
libraries, namely the Win32 API.


Then the Platform SDK is lying. From the documentation for ExitWindowsEx():
"To shut down or restart the system, the calling process must use the
AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For
more information, see Running with Special Privileges.
Windows Me/98/95: ExitWindowsEx does not work from a console application."
http://msdn.microsoft.com/library/en...twindowsex.asp

--
Unforgiven

Jul 22 '05 #8
"JKop" <NU**@NULL.NULL> wrote in message
news:CR*****************@news.indigo.ie...
Unforgiven posted: Shutting down the system was all I ever did when I started out with
Win32 programming.


LOL, same thing happened to me. Sometimes even required
a reinstall. :-)

-Mike
Jul 22 '05 #9

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

Similar topics

0
by: LJ | last post by:
I have been getting this message and can't resolve the problem. I have checked the AntiVirus software and added the application directory to the exculsion list. The application is on a web farm,...
4
by: Hari Koduru | last post by:
Hi All, I am getting the following exception in an ASP.NET application. Exception Details: System.InvalidOperationException: Application is restarting. I have been to the following Support...
7
by: Gene | last post by:
I have a Windows Service (VB.NET) that runs 24/7. It queries a Web service 5 to 10 times per hour. About 2 or 3 times a month, it fails. The log indicates that it sends the request to the Web...
2
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same...
7
by: GTi | last post by:
Does anyone have any good code for a self restarting application? Sometimes I need to exit my application and start it again, what is the best method of doing this in a windows form application....
9
by: woolley.dean | last post by:
The problem we are having is with the worker process restarting after one minute of being started up. We had a website running in .Net 1.1 and switched it over to .Net 2.0. The site is running on...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Following the samples online, we implemented a windows service in .Net. Like most services, there's a worker thread actually doing stuff in the background. The problem we've run into is...
3
by: gourmet | last post by:
Hello! I need to restart the "Windows Audio Service" (audiosrv) via C#. I'm using the ServiceController Class to do this. It is no problem under XP and no problem under vista if UAC is...
7
by: John | last post by:
Hi Is there a way to restart a winform app in case of a serious error? Thanks Regards
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.