System shutdown code?

This is a discussion on System shutdown code? within the C++ Programming forums, part of the General Programming Boards category; Hi all!!! Can any one help me out with some C++ code to shut down windows(XP) or an exe file ...

  1. #1
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765

    Question System shutdown code?

    Hi all!!!

    Can any one help me out with some C++ code to shut down windows(XP) or an exe file to do so. I want to use it in my program.

    Code:
    #include "SysInfo.h"
    #include <conio.h>
    #include <iostream.h>
    
    //class constructor
    SysInfo::SysInfo()
    {
    
    }
    
    //class destructor
    SysInfo::~SysInfo()
    {
    
    }
    
    void SysInfo::time(int xH, int xM)
    {
        int hour,min,sec;
        asm {
        mov AH, 0x2C
        int 0x21
        }
    
        hour = _CH;
        min = _CL;
        sec = _DH;
    
    
    
       if ((min == xM) && (hour == xH))
       {
            //this is where the shut down code comes
            clrscr();
            cout << "System shut down";
            getch();
       }
    
       if (sec == 0)
       {
           cout << hour << ":" << min << ":" << "00";
       }
       else if (sec < 10)
       {
            cout << hour << ":" << min << ":" << "0" << sec;
       }
       else
       {
            cout << hour << ":" << min << ":" << sec;
       }
    }

    The rest of the code is here :
    Attached Files Attached Files

  2. #2
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Got something else thoug....

    WinXP has a built in command called "shutdown" in command prompt. All I have to do is call that function with all the corect arguments within my program...And TADA!!!

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    There are several solutions depending on the location of the client system. You will need one or more of these Win32 API.

    ExitWindow()
    ExitWindowEx()
    InitiateSystemShutdown()
    AbortSystemShutdown()

    You must have adequate security privlege to reboot and shutdown a client system.

    Kuphryn

  4. #4
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Note that I'm not programming a windows app but C++ Standard dos app.

    This app runs in the back waiting for a given time(user defined) to arrive and the shuts down.

    *Borland C++ 5.02*
    Last edited by biosninja; 11-12-2002 at 12:15 PM.

  5. #5
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    include system.h

    call

    system("shutdown");
    or
    system("quit");

    or whatever the command is

  6. #6
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    include system.h

    call

    system("shutdown");
    or
    system("quit");

    or whatever the command is
    I know. "shutdown \l"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Operating system construction
    By AdamLAN in forum Tech Board
    Replies: 7
    Last Post: 03-05-2005, 12:31 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 04:39 PM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  4. Azbia - a simple RPG game code
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 05-03-2002, 06:59 PM
  5. Ranking System Code?
    By Kavine in forum C++ Programming
    Replies: 2
    Last Post: 12-31-2001, 07:20 AM

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