#include <Windows.h> #include <stdlib.h> void main() { while (1) { HWND win = GetDesktopWindow();//获取桌面 HDC windc = GetWindowDC(win);//获取桌面的显示 HDC Memdc = CreateCompatibleDC(0);//获取位图的句柄 //导入图片 HBITMAP bit = (HBITMAP)LoadImage((HINSTANCE)win, TEXT("1.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); SelectObject(Memdc, bit); BitBlt(windc, 100,0, 400, 300, Memdc, 0, 0, SRCCOPY); } }
#include <Windows.h> #include <stdlib.h> void main() { while (1) { HWND win = GetDesktopWindow();//获取桌面 HDC windc = GetWindowDC(win);//获取桌面的显示 HDC Memdc = CreateCompatibleDC(0);//获取位图的句柄 //导入图片 HBITMAP bit = (HBITMAP)LoadImage((HINSTANCE)win, TEXT("1.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); SelectObject(Memdc, bit); BitBlt(windc, 100,0, 400, 300, Memdc, 0, 0, SRCCOPY); } }