Restarting windows from c++

Discussion in 'C++' started by CRE, Jul 2, 2004.

  1. CRE

    CRE Guest

    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/
    CRE, Jul 2, 2004
    #1
    1. Advertising

  2. On Thu, 01 Jul 2004 21:57:01 -0800, CRE <> 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
    John Harrison, Jul 2, 2004
    #2
    1. Advertising

  3. CRE

    Mike Wahler Guest

    Re: [OT, welcome msg, link] Restarting windows from c++

    "CRE" <> wrote in message
    news:eek:psahxhb0nxqbskj@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
    Mike Wahler, Jul 2, 2004
    #3
  4. CRE

    JKop Guest

    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
    JKop, Jul 2, 2004
    #4
  5. int main()
    > {
    > ExitWindowsEx(....
    > }
    >


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

    Rainer
    Rainer Hausbach, Jul 2, 2004
    #5
  6. CRE

    Unforgiven Guest

    "Rainer Hausbach" <> wrote in message
    news:cc3d9v$63$...
    > 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
    Unforgiven, Jul 2, 2004
    #6
  7. CRE

    JKop Guest

    Unforgiven posted:

    > "Rainer Hausbach" <> wrote in message
    > news:cc3d9v$63$...
    >> 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
    JKop, Jul 2, 2004
    #7
  8. CRE

    Unforgiven Guest

    "JKop" <> wrote in message
    news:CRcFc.3689$...
    > Unforgiven posted:
    >
    >> "Rainer Hausbach" <> wrote in message
    >> news:cc3d9v$63$...
    >>> 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-us/sysinfo/base/exitwindowsex.asp

    --
    Unforgiven
    Unforgiven, Jul 2, 2004
    #8
  9. CRE

    Mike Wahler Guest

    Re: [OT] Restarting windows from c++

    "JKop" <> wrote in message
    news:CRcFc.3689$...
    > 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
    Mike Wahler, Jul 2, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LJ
    Replies:
    0
    Views:
    1,100
  2. Mark Feather

    Problems after restarting IIS ????

    Mark Feather, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    447
    Mark Feather
    Jul 14, 2003
  3. Simon Weaver

    restarting IIS from within ASP.NET

    Simon Weaver, Jul 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    453
    Simon Weaver
    Jul 22, 2003
  4. Bosh
    Replies:
    0
    Views:
    733
  5. Stephen
    Replies:
    2
    Views:
    1,261
    Stephen
    Mar 1, 2006
Loading...

Share This Page