Thread: Lockdown program

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Lockdown program

    I work in a public place where I have to deal with NT 4.0 machines and I can't be logging in and out manually all the time so I was wondering if anyone could help me create a program that would use a username and pass to get out of the program. I am a newb to programming and on chapter 2 of Beginning C++ Game Programming.
    Currently I have a makeshift program that passlocks it in fullscreen mode and doesn't display the text whilst typing the pass but you can get around it by using alt enter. Is there any way to stop that?
    Heres what I have to far:
    Code:
    //Roarke Password Lock
    
    #include <iostream>
    #include <windows.h>
    #include <string>
    #include <stdlib.h>
    
    using namespace std;
    void fullscreen()
    {
    keybd_event(VK_MENU,0x38,0,0);
    keybd_event(VK_RETURN,0x1c,0,0);
    keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
    }
    int main()
        {
        fullscreen();
        int leave = 0;
        while (leave == 0)
        {
              system("CLS");
              cout << "\n\tRoarkes Computer Passlock.";
              string user, pass;
              cout << "\n\nUsername: ";
              cin >> user;
              cout << "\nPassword: ";
              SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x0000);
              cin >> pass;
              SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x0007);
              if((user == "Herc" && pass == "testing") || (user == "NumBer2" && pass == "hello"))
              {
                        cout << "\n\n\t\tAccepted. Thank you."<<endl;
                        system("PAUSE");
                        break;
              }
              else
                  continue;
                  }
              return 0;
    }
    Any ideas?
    Yes, I picked up the fullscreen and the hide pass from these forums.
    No, it doesn't have to be portable just has to work on 95/nt4workstation/98/xp/200/me.. basically all windows. Thanks

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    It doesn't matter. Even if you were to disable Alt+Enter, the user could still use ctrl+alt+del to close your program. Locking down a Windows computer is actually very hard to do. The only way I can think of doing it is by hooking API functions in Kernel32.dll

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You don't have to log-off to protect your account, just use the 'Lock Computer' feature. It should be available by pressing Ctrl+Alt+Del.

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    On WinXP you could just go to the logon screen and require a password to login (locking is not the same as logout) and you could call LockWorkStation without going into standby. Essentially the same thing as WinKey + L:
    Code:
    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0500
    #endif
    
    #include <windows.h>
    #include <powrprof.h>
    
    int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int )
    {
    	if(LockWorkStation( ))
    	{
    		Sleep(2500);
    		SetSuspendState( FALSE, FALSE, FALSE );
    	}
    		
        return 0;
    }
    On Win95 there was some screensaver API call that you could invoke and have your program act like a passworded screensaver. Darned if I can remember it after all this time though... I think something like SPI_SCREENSAVERRUNNING or SPI_SETSCREENSAVERRUNNING, or SPI_GETSCREENSAVERRUNNING was part of the call. I'm not so sure what would work best on versions in between.

    Regards,
    Brian
    Last edited by Br5an; 01-25-2006 at 03:48 AM.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    2
    The problem with using the lock feature is that I don't have the password and someone else has to log in for me and hes kind of busy...
    There are ways to disable ctrl+alt+dlt and alt+enter, I've found them I'm just too much of a newb to port them into my program as I can't figure em out...
    Those two are the most common and thats all I would have to delete.
    Is there a way you can set something to happen in your program instead of windows?
    I could display something funny.. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM