I am writing a small c++ program that should react to the sc_screensaver and sc_monitorpower event.

this should run in background hence no gui is intended.

Since i have no experience with the windows api yet, i am struggling a lot with this.

A already googled a lot and found many approaches which either i dont understand or dont work.

Can anyone of you give me a hint? I read its about catching the wm_syscommand but that seems to be difficult because i dont have a window.

有帮助吗?

解决方案

The only way to get messages is by a message loop and a window procedure.

If your program does not have a visible gui, you have to create a message-only window for that purpose, and your main must have the code to create it and to listen windows messages (note: "windows" here, refers to the system, not the gui).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top