Reputation: 10380
So, a windows screensaver is just an exe that is passed one of 3 parameters.
/c for config screen
/s for fullscreen
/p <hwnd> for the little preview window.
I have everything working peachy except I have multiple processing running (this is the problem).
When you have the windows screensaver picker window open and select my screensaver, it launches it with /p so that it can show a preview. If you click the settings button, it will call my sreensaver again with /c. Now I there are two processing running. When I close the dialog, my process ends, but windows is now calling my screensaver again with /p . The processes keep adding up.
How should I handle this problem? I dont' see any documentation on the subject. I am hoping someone out there has done this before.
I don't want to monitor other processes to keep only one running. There has to be a solution I'm not seeing.
After further investigation, I see that windows passes messages to your screensaver: http://msdn.microsoft.com/en-us/library/cc144066%28v=vs.85%29.aspx
I setup a filter to catch the messages. I am getting everything but destroy. LOL. I would assume that it would pass WM_DESTROY to tell you to bail.
Upvotes: 1
Views: 248
Reputation: 10380
Turns out that I answered my own question. Refer to the msdn link above. You must monitor the messages and on WM_DESTROY, you kill your process. – HCHogan just now edit
Upvotes: 1
Reputation: 1063
Why not just look at the arguments to see if it's running in preview mode, and then alter your code to not do whatever you are trying to avoid,
or store the HWND in the registry and then use that to see if the preview is still running when your screensaver starts normally
Upvotes: 0