having a program shut down windows

This is a discussion on having a program shut down windows within the C++ Programming forums, part of the General Programming Boards category; Ok I have a Q related to the password problem I reported earlier. I am using the same program but ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    Question having a program shut down windows

    Ok I have a Q related to the password problem I reported earlier.
    I am using the same program but I want it to shutdown the computer if the password is wrong. Is there any way I can do this? I can make a shortcut that restarts the computer by making a new shortcut and pasteing this in the command line C:\windows\rundll.exe user.exe,exitwindowsexec . I wonder if I could somehow incorporate this into my password program. I can make the program run on startup, therefore creating a blockade, to say, keep youger siblings off when you don't want them in your room while you are trying to do something...
    My code...
    #include <iostream.h>
    #include <string.h>
    int main()
    {
    char *t=new char[20];
    char *x=new char[20];
    x="trey";
    cout<<"Enter password, please: ";
    cin.getline(t, 20, '\n');
    if (!strcmp(t, x))
    {
    cin.get();
    }
    else
    {
    cin.get();
    //This is where I want the shutdown to be...
    }
    return 0;
    }

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    >x="trey";

    This is a memory leak. If you want to copy a string, use strcpy.
    Alternativly, don't allocate memory with new. You will need to delete the memory you allocated with new later in the program.

    Look up the ExitWindowsEx function in your helpfile or on www.msdn.microsoft.com

    A board search might have helped, too. This is a topic discussed once or twice every two weeks.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    75
    sounds like a mischevious program...

  4. #4
    Registered User skyline's Avatar
    Join Date
    Dec 2001
    Posts
    49
    I can make the program run on startup, therefore creating a blockade
    but couldn't you just close this program or am i missing something?

  5. #5
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Hey Skyline - I'm just curious - where'd you get your name?

  6. #6
    Registered User skyline's Avatar
    Join Date
    Dec 2001
    Posts
    49

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. Replies: 6
    Last Post: 01-01-2007, 06:36 AM
  4. Replies: 2
    Last Post: 12-22-2006, 07:45 PM
  5. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM

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