I want to get bitmap data of windows desktop wallpaper. And, I want to draw some text directly to the bitmap.
First, I tried getting bitmap data by following code.
#include <windows.h>
#include <Commctrl.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev,
LPSTR cmdLine, int showCmd)
{
CoInitialize(NULL);
// find Progman
HWND hProgman = FindWindow("Progman", "Program Manager");
// find DefView
HWND hDefView = FindWindowEx(hProgman, NULL, "SHELLDLL_DefView", NULL);
// find SysListView
HWND hListView = FindWindowEx(hDefView, NULL, "SysListView32", NULL);
char filename[512] = {0};
LVBKIMAGE lvbki;
lvbki.ulFlags = LVBKIF_SOURCE_HBITMAP;
lvbki.hbm = NULL;
lvbki.pszImage = filename;
lvbki.cchImageMax = 512;
lvbki.xOffsetPercent = 0;
lvbki.yOffsetPercent = 0;
int ret = ListView_GetBkImage(hListView, &lvbki);
if (ret == 0) {
MessageBox(NULL, TEXT("GetBkImage failed!"), TEXT("err"), 0);
return -1;
}
if (lvbki.hbm == NULL){
MessageBox(NULL, TEXT("hbm is NULL"), TEXT("err"), 0);
return -1;
}
MessageBox(NULL, TEXT("FINISHED"), TEXT("msg"), 0);
CoUninitialize();
return 0;
}
This code's result is "hbm is NULL". It is wrong code?
My question is how to get bitmap data that displayed as desktop wallpaper on SysListView32? And, is it possible?
regards.