| | |
Quick question
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Could anyone inform me of how I would call the screen saver on windows xp?
Edit: Just did some research on MSDN and found the WM_SYSCOMMAND, and i see something about calling the screen saver in there, but i am confused on how to use it. Any help? Thanks guys
Edit: Just did some research on MSDN and found the WM_SYSCOMMAND, and i see something about calling the screen saver in there, but i am confused on how to use it. Any help? Thanks guys
Last edited by clutchkiller; Jan 2nd, 2009 at 3:55 pm.
>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!
Leave the computer idle until it's automatically put on.
Didn't look closely at this but it looks like it might be useful. http://www.dreamincode.net/forums/showtopic17214.htm
Didn't look closely at this but it looks like it might be useful. http://www.dreamincode.net/forums/showtopic17214.htm
Last edited by twomers; Jan 2nd, 2009 at 3:56 pm.
i mean using c++ and making an app out of it lol.
Edit: I dont want to create a screen saver, but call
MSDN:
SC_SCREENSAVE
Executes the screen saver application specified in the [boot] section of the System.ini file.
Im just confused on how to use it. Thanks
Edit: I dont want to create a screen saver, but call
MSDN:
SC_SCREENSAVE
Executes the screen saver application specified in the [boot] section of the System.ini file.
Im just confused on how to use it. Thanks
Last edited by clutchkiller; Jan 2nd, 2009 at 4:07 pm.
>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!
C++ Syntax (Toggle Plain Text)
#include <windows.h> #include <iostream> using namespace std; int main() { SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0); return 0; }
Last edited by Comatose; Jan 2nd, 2009 at 7:08 pm.
thx alot comatose, that works, but can u explain it to me? Also, say i wanted to allow the user to set a password to use on resume each time the app was run, any suggestions? I dont know much about win programming. Thanks!
Last edited by clutchkiller; Jan 2nd, 2009 at 9:37 pm.
>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!
sure, windows.h includes everything that we need. The standard C++ stuff, is just the includes, using namespaces (the namespaces and the #include <iostream> isn't even needed...it just came with the Code::Blocks IDE Blank Project, so I just left it) . So, Basically, the include directive tells the pre-compiler that we want to copy the contents of <windows.h> into our file at the top. The next step is the main function, known as the exe's entry point (the first piece of code that will run when the OS launches it) The only real line of code in the program is the SendMessage call, which is found in the windows.h file... SendMessage is a function used to basically make another window/program behave as you would want it to (ie: you can send messages to have a window minimize, maximize, close... whatever) .
SendMessage wants to know what window to send the message to. We used another function (defined in windows.h) called GetDesktopWindow, which will give us the "handle" or "hwnd" of the Desktop Window. An Hwnd is a unique hex value assigned to a window so that it can be identified by the OS. Every window has one. So, we get the hwnd for the desktop (with GetDesktopWindow) and use that hwnd, so that SendMessage knows which window we are sending a message to. The WM_SYSCOMMAND, let's the window know that we are about to send it a system command of some kind. The SC_SCREENSAVE (both WM_SYSCOMMAND and SC_SCREENSAVE are also defined in windows.h) tells the window that the particular system command, is to launch the screensaver. The zero is pretty much just a place-holder... in more complicated sendmessages it becomes needed for additional information, but 90% of the time it is zero. The return 0 (since we are returning from the main function) exits the program.
SendMessage wants to know what window to send the message to. We used another function (defined in windows.h) called GetDesktopWindow, which will give us the "handle" or "hwnd" of the Desktop Window. An Hwnd is a unique hex value assigned to a window so that it can be identified by the OS. Every window has one. So, we get the hwnd for the desktop (with GetDesktopWindow) and use that hwnd, so that SendMessage knows which window we are sending a message to. The WM_SYSCOMMAND, let's the window know that we are about to send it a system command of some kind. The SC_SCREENSAVE (both WM_SYSCOMMAND and SC_SCREENSAVE are also defined in windows.h) tells the window that the particular system command, is to launch the screensaver. The zero is pretty much just a place-holder... in more complicated sendmessages it becomes needed for additional information, but 90% of the time it is zero. The return 0 (since we are returning from the main function) exits the program.
Thank you very much for the in depth explanation, I am already familiar with the first half, but its always good to make sure your on top of your game, thanks a lot!
>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!
The Password issue is a whole lot uglier. Since I believe it was win2k or so, the password to get into the system from the screensaver is the account password. So, if you logged into XP as ClutchKiller, then the password for the screen saver is the same one that you used to log in to XP. So, what you are essentially looking for, is how do you change the account password.... and then put it back to what it was before..
Your Welcome
Your Welcome
Last edited by Comatose; Jan 2nd, 2009 at 10:15 pm.
hah, I was just scheming, and you tell me what you think about this idea, but what if i just ask for user input for a variable, and then once the screen saver is interrupted, i can do something like lock the desktop window until user inputs the correct variable code that was entered in console before SC_SCREENSAVE was called. So i guess instead of going through OS, just go through console. Sound doable? Maybe have the app detect mouse movement and thats when the console pops up again, and that would disable the screen saver as well, so that might reduce on the technicality of the source.
>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!
![]() |
Similar Threads
- Quick question (C++)
- quick question w\ a program (Java)
- nevermind: ignore arrays problem - quick question (C++)
- A quick question about "rank" (DaniWeb Community Feedback)
- Quick question on a loop. (C++)
- A quick question (Game Development)
- quick question (C++)
- Question about 321Studios (Windows Software)
- Quick question (Troubleshooting Dead Machines)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
Other Threads in the C++ Forum
- Previous Thread: C++ add days to date
- Next Thread: for loop as a macros
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






