当前位置:网站首页>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;
}保存的图片位置:

边栏推荐
- 动态规划经典题目三角形最短路径
- [network planning] 1.3 packet switching and circuit switching in the network core
- 圖的最短路徑問題 詳細分解版
- Random points in non overlapping rectangles
- Download Google gcr IO image
- Is it safe to open an account for stock speculation in Shanghai?
- SQL审核 | “云上”用户可以一键使用 SQLE 审核服务啦
- Dual wing layout
- Baidu PaddlePaddle paddlepaddle latest series AI course playback address
- 海贼oj#148.字符串反转
猜你喜欢

The JVM determines whether an object can be recycled

哈工大软件构造复习——LSP原则,协变和逆变

【无标题】测试下啊

Detailed decomposition of the shortest path problem in Figure

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
![[network planning] 3.2 transport layer - UDP: connectionless service](/img/a8/74a1b44ce4d8b0b1a85043a091a91d.jpg)
[network planning] 3.2 transport layer - UDP: connectionless service

What is MYCAT? Get to know you quickly

非重叠矩形中的随机点

字符串时间排序,对时间格式字符串进行排序

Synchronized keyword for concurrent programming
随机推荐
Complete uninstallation of MySQL under Linux
Yii2 activerecord uses the ID associated with the table to automatically remove duplicates
UUID quick explanation
非重叠矩形中的随机点
海贼oj#448.抽奖
What are absolute and relative paths, and what are their advantages and disadvantages?
电脑录屏免费软件gif等格式视频
AQS explanation of concurrent programming
[kingcraft] 3.1 link layer - functions of data link layer
阿里云配置SLB(负载均衡)实例
五大类型负载均衡的原理场景详解
【无标题】6666666
How word inserts a guide (dot before page number) into a table of contents
Kubernetes入门介绍与基础搭建
On the quality assurance system of youzan search V2021
海贼oj#148.字符串反转
Test it first
浅谈有赞搜索质量保障体系 v2021
[network counting] 1.4 network delay, packet loss and throughput
Is it safe to open an account for stock speculation in Shanghai?
