| | |
Cant solve what is wrong
![]() |
Here is my code that i am working on. Upon running the exe, it asks the user for a temporary password. After that, the screen saver pops up. Upon exiting the screen saver, the console will ask you for the temporary pass that you entered in order to renable the desktop.
So my question is, everything is compiling fine with no errors or warnings, but when i run the program i have a few problems. Everything works up to when the console asks for the password again to initialize the desktop, instead of attempting to verify the correct password, the program just ends.
So my question is, everything is compiling fine with no errors or warnings, but when i run the program i have a few problems. Everything works up to when the console asks for the password again to initialize the desktop, instead of attempting to verify the correct password, the program just ends.
c++ Syntax (Toggle Plain Text)
#include <windows.h> #include <iostream> #include <winable.h> using namespace std; int rePass(0); //first password int rePassb(1); //password to compare int main() { cout << "Set Recovery pass: "; cin >> rePass; cin.get(); SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0); //Start screen saver //Saftey precaution to prevent instant screen saver disable by accedental mouse movement BlockInput(1); Sleep(2000); BlockInput(0); //Sloppy idle process until screen saver is disabled do{ system("PAUSE"); } while(SC_SCREENSAVE == 1); Sleep(2000); EnableWindow(GetDesktopWindow(), 0); //Deactivate desktop //Tests if the intial password that was set matches the new password entered in order to enable desktop PassCheck: cout << "Enter Recovery Pass: "; cin >> rePassb; if(rePassb == rePass) { cout << "Re-Enabling Windows..."; EnableWindow(GetDesktopWindow(), 1); //Enable desktop if password was entered sucessfully Sleep(2000); } else { cout << "Incorrect Password..." << endl << "Enter Recovery Pass: "; goto PassCheck; //Sends user back up to initial password entry } cin.get(); return 0; }
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
SC_SCREENSAVE is a windows message.... it's a constant. A constant hex value (0XF140) and will never be 1. So your do loop will only run once, no matter what. If it where a while loop instead, the system("pause"); would never run, because the test condition would happen first.... I mean to say SC_SCREENSAVE doesn't tell you if the screensaver is on or not... it's just used by windows to tell the system to trigger the screensaver. Also, system("pause") is usually frowned upon, because it's not really portable, and requires a call to (I think) the kernel. cin.ignore(); would probably do the trick. Goto's.... while they are perfectly code legal, they are 90% unacceptable. They lead to "Spaghetti Code" where the line of execution keeps jumping around (this was required in asm.... jne
). There are usually ways to avoid using goto's, and it's usually a good idea to avoid them (gotos). The enablewindow call (the call to disable the desktop) doesn't actually disable it. I can still work with it as though nothing had happened. This actually works to lock the desktop, but none of the opened windows or taskbar/start button:
). There are usually ways to avoid using goto's, and it's usually a good idea to avoid them (gotos). The enablewindow call (the call to disable the desktop) doesn't actually disable it. I can still work with it as though nothing had happened. This actually works to lock the desktop, but none of the opened windows or taskbar/start button: EnableWindow(FindWindowEx(FindWindow("Progman", NULL), HWND(0), "ShellDll_DefView", NULL), FALSE); So... you may have to do something similar to block the taskbar/startbutton and something to hide any open windows. ![]() |
Similar Threads
- My logic must be ALL wrong , help on Average. (C)
- help me solve my virus problem (Viruses, Spyware and other Nasties)
- Can Anyone Solve This? (Viruses, Spyware and other Nasties)
- How to delete a data structure in Builder 6.0? (C++)
- May solve some ie problems! (Windows NT / 2000 / XP)
- Flickering curser with all my games :( possible wrong setting?? (Monitors, Displays and Video Cards)
- Anything wrong with deleting all INDEX.DAT files? (Web Browsers)
- something wrong with IE6 (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Don't Erase Contents of Text File
- Next Thread: Launching an application
| Thread Tools | Search this Thread |
api application array based binary bitmap c# c++ c/c++ char class classes code coding compile compression console conversion count cpm delete deploy deque desktop developer dialog directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer introductory java lib linkedlist linkednodes linker loop looping loops map math matrix memory multiple news node numbertoword output parameter pointer problem program programming project python random read recursion reference rpg security sorting string strings temperature template test text text-file tree url variable vector video whyisthiscodecausingsegmentationfault win32 windows winsock wordfrequency wxwidgets






