VC++ 设置桌面壁纸
Windows Shell API提供了接口IActiveDesktop来完成墙纸的设置。
//IActiveDesktop 接口方法表 (详情参见MSDN)
AddDesktopItem
AddDesktopItemWithUI
AddUrl
ApplyChange
GenerateDesktopItemHtml
GetDesktopItem
GetDesktopItemByID
GetDesktopItemBySource
GetDesktopItemCount
GetDesktopItemOptions
GetPattern
GetWallpaper
GetWallpaperOptions
ModifyDesktopItem
RemoveDesktopItem
SetDesktopItemOptions
SetPattern
SetWallpaper
SetWallpaperOptions
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
BOOL SetWallpaper(CString &strPicFile, DWORD dwStyle)
{ HRESULT hr = S_OK; IActiveDesktop* pIAD = NULL; //创建接口的实例 hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER, IID_IActiveDesktop, (void**) &pIAD ); if (FAILED(hr)) { return FALSE; } //将文件名改为宽字符串,这是IActiveDesktop::SetWallpaper的要求 }; LPTSTR lpStr = strPicFile.GetBuffer(strPicFile.GetLength() ); MultiByteToWideChar(CP_ACP, , wszWallpaper, MAX_PATH); strPicFile.ReleaseBuffer(); //设置墙纸 ); if (FAILED(hr)) { return FALSE; } //设置墙纸的样式 WALLPAPEROPT wpo; wpo.dwSize = sizeof(wpo); wpo.dwStyle = dwStyle; hr = pIAD->SetWallpaperOptions(&wpo, ); if(!SUCCEEDED(hr)) { return FALSE; } //应用墙纸的设置 hr = pIAD->ApplyChanges(AD_APPLY_ALL); if(!SUCCEEDED(hr)) { return FALSE; } //读取墙纸的文件名并打印在debug窗口内 ); CString strFile = wszWallpaper; TRACE(strFile); //释放接口的实例 pIAD->Release(); return TRUE; } BOOL EnableActiveDesktop(BOOL bEnable) |
Demo下载:http://pan.baidu.com/s/1bpjFyNX
VC++ 设置桌面壁纸的更多相关文章
- UWP 设置桌面壁纸、锁屏图片
private static Uri imgUri = new Uri("ms-appx:///pic1.jpg"); private async void btnSetWallp ...
- sakura设置桌面壁纸
下下载steam上的Wallpaper Engine 先将sakura.html下载为html文件. 再从文件打开 就保存了 再加载保存,就一直是了
- c++ 设置桌面壁纸(win)
#include <iostream> #include <Windows.h> int main() { const char* path = "C:\\Users ...
- python爬虫-抓取acg12动漫壁纸排行设置为桌面壁纸
ACG-wallpaper 初学python,之前想抓取P站的一些图片来着,然后发现acg12这里有专门的壁纸榜单,就写了个抓取壁纸作为mac桌面壁纸玩玩. 功能:抓取acg12壁纸榜单的动漫壁纸,并 ...
- Windows 聚焦的锁屏壁纸设置为桌面壁纸
需求: Windows的锁屏壁纸偶尔遇到非常喜欢的壁纸,想设置为桌面壁纸. 步骤如下: 1. “Windows 聚焦”的锁屏壁纸都保存在隐藏文件夹 --- Assets里. a. 打开“资源管理器 b ...
- 【Win10应用开发】自定义桌面壁纸
调用通用的API来设置桌面壁纸,是一件既简单又有趣的事情,结合XAML可以生成图像的特性,你甚至可以做一个应用,让用户用他所拍的照片做成一张自定义壁纸,然后作为桌面壁纸. 这个API是通用的,应用运行 ...
- Win10家庭版设置桌面右键更换桌面壁纸
Win10家庭版设置桌面右键更换桌面壁纸.. ------------------------- 这是设置之前的右键快捷菜单.. ------------------------- 开始设置:右键桌面 ...
- 为你的Windows7设置动态壁纸
From:http://www.cnblogs.com/killerlegend/p/3644014.html By KillerLegend DreamScene是Vista上的一个功能,可以让你设 ...
- android设置动态壁纸 (Wallpaper) 介绍
当进入改壁纸的设置页面 但是还没有设置时 09-21 07:55:05.575: INFO/System.out(1337): service onCreate09-21 07:55:05.614: ...
随机推荐
- iOS开发- 隐藏键盘总结
一.隐藏自身软键盘 当对于有多个UITextField控件都想通过点击"Return"来隐藏自身软键盘的情况.这时的最好办法是使用Did End on Exit事件.在点击软键盘右 ...
- python--内置函数清单
转自:http://www.cnblogs.com/vamei/archive/2012/11/09/2762224.html Python内置(built-in)函数随着python解释器的运行而创 ...
- 1 - Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Discuss: 1. ...
- MSSQL如何访问ORACLE里的表
环境: MSSQL:2008 ORACLE DB:10.2.0.1 之前一直没有接触MSSQL,最近因需要MSSQL访问ORACLE里的表,下面是MSSQL连接ORACLE的配置过程. 1 ...
- html使用自我知识点总结
1. 不要忘结束标签 <p>This is a paragraph <p>This is a paragraph 未来的HTML版本号不同意省略结束标签. 2. 没有内容的HT ...
- Android Studio 更新gradle插件
今天更新了CentOS, 更新了java版本. 然后gradle跪了..... 不吐槽java版本的兼容性问题了.... 反正有他自己的理由.... 那么就更新gradle咯.... 下面是方法... ...
- 每日英语:Why Chinese Companies Lack Homegrown Luxury Brand Power
Chinese companies build iPads, high-speed trains and world-class telecom gear, but they can't seem t ...
- ngBind {{}} ngBindTemplate
1.首先我们最常使用的一个绑定表达式的指令是ngBind,比如在一个div标签中我们可以这样使用: <div ng-bind="vm.info"></div> ...
- 关闭IOS更新功能(ios4/5/6)
防止IOS升级: 工具:ifunbox 展开/System/Library/LaunchDaemons,将下面4个文件删除(不推荐)或者改名(后缀也得改),改名后记得必须重启. com.apple.m ...
- ubuntu server执行sudo出现"no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory"
[Ubuntu] 執行 sudo 時,出現 "no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory ...