当前位置:网站首页>C语言实现设置桌面壁纸
C语言实现设置桌面壁纸
2022-06-10 23:38:00 【星与梦想star_dream】
关键代码:
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\1.jpg", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
更多资料,请参考百度百科
今天的主角是:如何通过C语言实现桌面壁纸
函数原型:
BOOL SystemParametersInfo(UINT uiAction,UINT uiParam,PVOID pvParam,UINT fWinlni);参数说明:
- uiAction:该参数指定要查询或设置的系统级参数。
- uiParam:uiParam 在参数说明中所有为ulParam均为错误。(一般取值0)
- pvParam:与查询或设置的系统参数有关。(如果设置壁纸,就填写图片地址)
- fWinlni:如果设置系统参数,则它用来指定是否更新用户配置文件。(取值0或下面表格中任意一项)
SPIF_UPDATEINIFILE 把新的系统参数的设置内容写入用户配置文件。 SPIF_SENDCHANGE 在更新用户配置文件之后广播WM_SETTINGCHANGE消息。
SystemParametersInfo函数有4个参数,主要为:(与函数原型相对应)
- SPI_SETDESKWALLPAPER:设置桌面壁纸。
- 第2个参数一般设置为0,即可。
- 第3个参数填上图片所在位置
- 第4个参数可以填0,或者SPIF_UPDATEINIFILE | SPIF_SENDCHANGE
代码示例(仅供参考)
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
void menu()
{
printf("----------------------\n");
printf("| 1.樱花 |\n");
printf("| 2.精美 |\n");
printf("| 3.风景 |\n");
printf("| 4.循环 |\n");
printf("----------------------\n");
}
int main()
{
int choice = 0;
int count = 10;
menu();
printf("请输入选项:");
scanf("%d",&choice);
switch(choice)
{
case 1:
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\1.jpg", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
break;
case 2:
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\2.jpg", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
break;
case 3:
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\3.png", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
break;
case 4:
while(count)
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\1.jpg", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
Sleep(2000);
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\2.jpg", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
Sleep(2000);
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\star-dream\\Pictures\\Saved Pictures\\3.png", SPIF_SENDCHANGE|SPIF_UPDATEINIFILE);
Sleep(2000);
count--;
}
break;
}
return 0;
}保存的图片位置:

边栏推荐
- LeetCode 8. 字符串转换整数 (atoi)(中等、字符串)
- Philips coo will be assigned to solve the dual crisis of "supply chain and product recall" in the face of crisis due to personnel change
- 海贼oj#148.字符串反转
- JVM 垃圾回收机制和常见的垃圾回收器
- Yii2 activerecord uses the ID associated with the table to automatically remove duplicates
- DevOps到底是什么意思?
- [no title] 4555
- Unity custom folder icon color personalized unity compiler
- Review of software architecture in Harbin Institute of technology -- LSP principle, covariance and inversion
- 对象作为点(Objects as Points) 个人总结
猜你喜欢

What is MYCAT? Get to know you quickly

Detailed decomposition of the shortest path problem in Figure

Yum source update
![[untitled] test](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled] test

Word在目录里插入引导符(页码前的小点点)的方法

浅谈有赞搜索质量保障体系 v2021

Fastdfs quick start

On the quality assurance system of youzan search V2021

Lucene mind map makes search engines no longer difficult to understand

跳转页面后回不去默认页面
随机推荐
市值215亿,这个四川80后会让电视机成为历史?
如何保证消息的顺序性、消息不丢失、不被重复消费
unity 网格面片生成抛物线,折线
String time sorting, sorting time format strings
动态规划经典题目三角形最短路径
Docking request mode
Complete uninstallation of MySQL under Linux
Test it first
负载均衡策略图文详解
Multipass中文文档-使用指引(目录页)
[network planning] 2.1.1 brief introduction to client server system and P2P system
Rich text activity test 1
Unity custom folder icon color personalized unity compiler
SQL statement -- enter the month, query the date (month, year, day), and output the month
LeetCode 1996. Number of weak characters in the game*
项目连接不到远程虚拟机The driver has not received any packets from the server.
Philips coo will be assigned to solve the dual crisis of "supply chain and product recall" in the face of crisis due to personnel change
Review of software architecture in Harbin Institute of technology -- LSP principle, covariance and inversion
[untitled] test
What is MYCAT? Get to know you quickly
