框架 MFC 修改桌面 桌布

2021-07-15 08:54:44 字數 2064 閱讀 2323

功    能:使用

iactivedesktop

介面獲取、設定和重新整理桌面背景(桌布)

開發環境:  vc\vs2005\vs2008\vs2010\vs2012\vs2013

新建專案:mfc應用程式(基於對話方塊)

#include #include

shlobj.h

shlwapi.h

包含了對檔案判別的api函式(pathfileexists、)

int getwall*****style()

return reint;

}cstring getwall*****()

else

}return cstring(g_szhomedir)+_t("\\")+refile;

}

getwall*****style

獲取桌布風格

getwall*****

獲取桌布的全路徑

檔名

sqwall*****.ini

內容

[param]

wall*****style=2

wall*****=desktop.bmp

wall*****style:桌布風格(0居中、1平鋪、2拉伸)

wall*****:自定義的檔名,需要與程式在同一目錄下(支援jpg、bmp、gif等格式)

bool setwall*****(cstring &strpicfile, dword dwstyle)

hr = piad->setwall*****(strpicfile, 0);

if(!succeeded(hr))

wall*****opt wpo;

wpo.dwsize = sizeof(wpo);

wpo.dwstyle = dwstyle;

hr = piad->setwall*****options(&wpo, 0);

if(!succeeded(hr))

if(!succeeded(hr))

wchar wszwall***** [max_path];

cstring strfile ;

hr = piad->getwall*****(wszwall*****, max_path, 0);

if(!succeeded(hr))

strfile = wszwall*****;

trace(strfile);

piad->release();

return true;

}

cocreateinstance

:建立介面例項

setwall*****

:設定桌面桌布

setwall*****options

:設定桌布風格

:應用桌布

getwall*****

:獲取當前使用桌布的名稱

bool enableactivedesktop(bool benable)

cocreateinstance

:建立介面例項

setdesktopitemoptions

:更新桌面

tchar g_szhomedir[max_path+1];

if (enableactivedesktop(true)==true)

return false;

}afxoleinit

: 初始化介面

getwall*****

:獲取桌布全路徑

getwall*****style

:獲取桌布風格

setwall*****

:更換桌布

enableactivedesktop

:重新整理桌面

Android獲取當前桌面桌布

這段時間專案有需求要獲取桌面的桌布來設成背景,發現網上很多同學都通過wall manager的getdrawable等api來獲取,這樣的確能獲得到桌布,但是要稍微注意一下。桌面的桌布可是很大很大的一張哦,你要直接用來設定成背景,那可是很醜的。所以我們需要稍微處理一下。大致思路就是把一張桌布切成幾片...

爬蟲爬取桌面桌布

import requests from bs4 import beautifulsoup import os import time import random import useragent interval 3 爬取的間隔時間 firstdir d netbian 總路徑 classific...

語言 批處理 批處理修改桌面 桌布

echo off reg add hkcu control panel desktop v wall d c mywall bmp f reg add hkcu control panel desktop v wall style t reg dword d 2 f rundll32.exe use...