Windows screensaver multiple instance

邮差的信 提交于 2019-12-13 18:26:55

问题


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.

Thanks

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.


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12203577/windows-screensaver-multiple-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!