Nooo!!!!!!!

This is a discussion on Nooo!!!!!!! within the C++ Programming forums, part of the General Programming Boards category; im new to c++ and have been writing the simple programs that i can in console apps. my hardest, simple ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    18

    Angry Nooo!!!!!!!

    im new to c++ and have been writing the simple programs that i can in console apps. my hardest, simple program yet has become hard. im trying to make a program that has timed shutdown. ie. you put in 10 minutes, and in 10 minutes your computer will shut off. i have been reading posts on how people have been trying to shut down their computers and all of the replies say that it isn't possible to do it in console mode. is this true? Here is what i have:
    #include <windows.h>
    #include <iostream.h>

    int main()
    {

    int timelef;
    cout<<"How long would you like to wait until you shut down your computer?:"<<endl;
    cin>>timelef;


    if (timelef<500) {
    Sleep(1000*60*timelef);
    ExitWindowsEx(); //this is giving me an error, too few arguments
    }
    if (timelef>500) {
    cout<<"Your number is too big"<<endl;
    }
    int exitme;
    cout<<"The program has finished, press a key and Enter to leave"<<endl;
    cin>>exitme;

    return 0;
    }
    //where x is the number of milliseconds to "sleep"
    //also be sure to capitalize sleep or it won't work i think
    im new

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    here is the function definition for ExitWindowsEx:

    BOOL ExitWindowsEx(

    UINT uFlags, // shutdown operation
    DWORD dwReserved // reserved, just pass as NULL
    );
    Parameters

    uFlags

    Specifies the type of shutdown. This parameter must be some combination of the following values:

    EWX_FORCE: Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.

    EWX_LOGOFF: Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
    EWX_POWEROFF: Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

    EWX_REBOOT: Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

    EWX_SHUTDOWN: Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

    dwReserved:

    Reserved; this parameter is ignored.


    Also, you need to state your units of time in your cout statement, so the user knows what amount of time he/she is typing in(minutes, seconds, miliseconds). I don't see any other apparant errors, though. Good Luck!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro!?
    By CammoDude91 in forum Game Programming
    Replies: 12
    Last Post: 07-29-2003, 12:39 PM
  2. MSVC++ Error... Nooo...
    By rmullen3 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 12:36 AM
  3. Error?? NOOO!!!!!!!
    By erikcn in forum C++ Programming
    Replies: 15
    Last Post: 05-30-2002, 10:57 AM
  4. menus
    By iain in forum Windows Programming
    Replies: 10
    Last Post: 08-18-2001, 03:03 AM
  5. compiler/editor/ide debate
    By cozman in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 08-12-2001, 06:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21