设置壁纸方法
2008-03-08 21:50:18 来源:WEB开发网核心提示:通过IActiveDesktop接口来实现 比如设置壁纸,就可以这样 IActiveDesktop *a; CoInitialize(NULL); if(SUCCEEDED(CoCreateInstance(Shlobj::CLSID_ActiveDesktop,NULL,CLSCTX_INPROC_SERVER,II
通过IActiveDesktop接口来实现
比如设置壁纸,就可以这样
IActiveDesktop *a;
CoInitialize(NULL);
if(SUCCEEDED(CoCreateInstance(Shlobj::CLSID_ActiveDesktop,NULL,CLSCTX_INPROC_SERVER,IID_IActiveDesktop,(void **)&a)))
{
WideString c = "C:\\My Documents\\yw2.jpg";
OleCheck(a->SetWallpaper(c.c_bstr(),0));
OleCheck(a->ApplyChanges(AD_APPLY_ALL));
a->Release();
}
CoUninitialize();
注重在cpp的第一行加入#define NO_WIN32_LEAN_AND_MEAN
并要#include <shlobj.h>
更多精彩
赞助商链接