C++Builder6.0实现windows桌面背景
哪位大侠有用C++Builder6.0做过桌面背景的,定时自动切换桌面背景,给个源码下 谢谢了
[解决办法]
弄个定时器, 定时调用下面的函数就行了:
// 根据nStyle指定的样式更改墙纸// 0: 居中显示, 1: 平铺显示, 2: 拉伸显示#include <registry.hpp>void __fastcall CrnSetDeskWallpaper(String strBmpFile, int nStyle){ TRegistry *reg = new TRegistry; reg->RootKey = HKEY_CURRENT_USER; reg->OpenKey("Control Panel\\Desktop", true); switch (nStyle) { case 0: // 居中显示 reg->WriteString("TileWallPaper", "0"); reg->WriteString("WallpaperStyle", "0"); break; case 1: // 平铺显示 reg->WriteString("TileWallPaper", "1"); reg->WriteString("WallpaperStyle", "0"); break; case 2: // 拉伸显示 reg->WriteString("TileWallPaper", "0"); reg->WriteString("WallpaperStyle", "2"); break; default: break; } ::SystemParametersInfo(SPI_SETDESKWALLPAPER, true, strBmpFile.c_str(), SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); delete reg;}// 测试: 拉伸显示// CrnSetDeskWallpaper("D:\\ccrun\\123.bmp", 2);