devxlogo

How to make application disable/invoke the current screen-saver

How to make application disable/invoke the current screen-saver

Question:
I have a small application that monitors Windows’ resources GDI and users as well as controlling Windows’ exit/restart/reboot. I would like it to be able to disable/invoke the current screen-saver as well. I can’t find anything in the Windows SDK to help me.

Answer:
The API function to enable and disable the screen-saver underWindows is SystemParametersInfo, a function responsible for getting and setting most of the control panel settings such as double-click speed, mouse trails, screensaver timeout, icon title wrap and screen-saver active.

The format of the command is as follows:

BOOL SystemParametersInfo(      UINT uiAction, // system parameter to query or set      UINT uiParam,  // depends on action to be taken      PVOID pvParam, // depends on action to be taken      UINT fWinIni   // user profile update flag     ); 
You will need to use the SPI_GETSCREENSAVEACTIVE action, which is decimal16, to get the current setting, and SPI_SETSCREENSAVEACTIVE action, whichis decimal 17. The uiParam should be set to the value TRUE/FALSE for the newsetting, and a Boolean passed by reference in pvParam to receive thecurrent setting.

See also  How College Students Can Shape the Future of Tech Responsibility
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist