小程序:VC++修改Windows桌面背景为黑白灰色(WinXP、Win7 64位)
2015-02-07 20:49
453 查看
直接上程序:
void CTestDlg::DoIt() { // TODO: Add your control notification handler code here LARGE_INTEGER litmp; LONGLONG qt1,qt2; double dft,dff,dfm; //获得时钟频率 QueryPerformanceFrequency(&litmp);//获得时钟频率 dff=(double)litmp.QuadPart; //获得初始值 QueryPerformanceCounter(&litmp); qt1=litmp.QuadPart; HDC hScrDC, hScreen; HBITMAP hBitmap; hScreen = ::CreateDC("DISPLAY", NULL, NULL, NULL); hScrDC =::CreateCompatibleDC(hScreen); int w = GetDeviceCaps(hScreen, HORZRES); int h = GetDeviceCaps(hScreen, VERTRES); hBitmap = CreateCompatibleBitmap(hScreen, w,h); if (hBitmap == 0) { AfxMessageBox("hbmScreen"); } if (!SelectObject(hScrDC, hBitmap)) { AfxMessageBox("Compatible Bitmap Selection"); } if (!BitBlt(hScrDC,0,0, w, h, hScreen, 0,0, SRCCOPY)) { AfxMessageBox("BitBlt"); } COLORREF rgb = 0; for (int i=0; i<w; i++) { for (int j=0; j<h; j++) { rgb = ::GetPixel(hScrDC, i, j); //int r = GetBValue(rgb); int g = GetGValue(rgb); //int b = GetRValue(rgb); rgb = RGB(g, g, g); ::SetPixel(hScrDC, i, j, rgb); } } if (!BitBlt(hScreen,0,0, w, h, hScrDC, 0,0, SRCCOPY)) { AfxMessageBox("BitBlt"); } //获得终止值 QueryPerformanceCounter(&litmp); qt2=litmp.QuadPart; //获得对应的时间值,转到毫秒单位上 dfm=(double)(qt2-qt1); dft=dfm/dff; CString str; str.Format("修改完成,耗时: %.3f秒", dft); SetWindowText(str); DeleteObject(hBitmap); DeleteDC(hScrDC); DeleteDC(hScreen); }
相关文章推荐
- 【C/C++学院】(2)函数/Lua/数组/恶搞程序(修改桌面背景,播放音乐)
- VC++实现像360安全桌面一样修改桌面背景
- 在程序中修改IP win7 winXP(正式)
- win7 64位系统双击桌面所有程序提示"文件没有与之关联的程序来执行"的解决方法
- 修改windows 2012/win8、win7远程桌面连接默认端口的方法
- VC++实现像360安全桌面一样修改桌面背景
- 用VC2013编译了一个程序,在Windows 8、Windows 7(64位、32位)下都能正常运行。但在Win XP,Win2003下运行时,却报错不能运行
- 【转载】VC修改程序背景
- 前两天用VC6做的修改远程桌面端口的命令行小程序,源码。
- 64位win7上32位程序访问64位windows 2008 r2上的oracle数据库
- 自己动手打造WinXP风格的Win7显示桌面程序
- 在程序中修改IP win7 winXP(参考1)
- Qt: windows修改切换桌面背景的风格(居中,平铺,拉伸等).
- 如何解决vista和win7在windows服务中无法与桌面程序交互的问题?
- Windows 2008 r2 64位系统修改远程桌面端口方法
- 修改windows 2012/win8、win7远程桌面连接默认端口的方法
- vc变成修改/设置桌面背景(1)
- Windows 2008 r2 64位系统修改远程桌面端口方法
- win7以上系统批处理修改注册表修改桌面背景图片
- Win7中修改程序背景颜色