Windows API one-day training (75) systemparametersinfo Function
In the face of the gorgeous windows desktop, I may feel a lot better at work, but I will always lose interest after a long time, and I always want to update the desktop images on a regular basis. How do software developers need to meet such requirements? Try to find the API function. So far, there have been a lot of software for changing desktop images, and they can make a lot of money. As a matter of fact, the demand for desktop images is also met by the current digital photo processing software. For example, when you travel back, you want to use photos as desktop images, you can set the image to a desktop image when processing the image. In this way, you need to use the systemparametersinfo function to complete this task. Of course, this function also has many other functions, such as obtaining the desktop workspace size.
The systemparametersinfo function declaration is as follows:
Winuserapi
Bool
Winapi
Systemparametersinfoa (
_ In uint uiaction,
_ In uint uiparam,
_ Inout_opt pvoid pvparam,
_ In uint fwinini );
Winuserapi
Bool
Winapi
Systemparametersinfow (
_ In uint uiaction,
_ In uint uiparam,
_ Inout_opt pvoid pvparam,
_ In uint fwinini );
# Ifdef Unicode
# Define systemparametersinfo systemparametersinfow
# Else
# Define systemparametersinfo systemparametersinfoa
# Endif //! Unicode
Uiaction is used as different operation parameters.
Uiparam is a set parameter.
Pvparam is a set or returned parameter.
Fwinini is the set parameter.
An example of calling a function is as follows:
#001 //
#002 // obtain system configuration information.
#003 // Cai junsheng 2007/11/16 QQ: 9073204 Shenzhen
#004 void getsystemparam (void)
#005 {
#006 // obtain the desktop wallpaper path.
#007 // spi_get1_wallpaper
#008 tchar chpath [max_path];
#009 if (systemparametersinfo (spi_get1_wallpaper, max_path, chpath, 0 ))
#010 {
#011 //
#012 outputdebugstring (chpath );
#013 outputdebugstring (_ T ("/R/N "));
#014}
#015
#016 // obtain the workspace size.
#017 // spi_getworkarea
#018 rect rcworkarea;
#019 if (systemparametersinfo (spi_getworkarea, 0, & rcworkarea, 0 ))
#020 {
#021 //
#022 const int nbufsize = 256;
#023 tchar chbuf [nbufsize];
#024
#025 wsprintf (chbuf, _ T ("% u, % u"), rcworkarea. Left, rcworkarea. Top,
#026 rcworkarea. Right, rcworkarea. Bottom );
#027
#028 outputdebugstring (chbuf );
#029 outputdebugstring (_ T ("/R/N "));
#030}
#031
#032}