How To CaptureScreen at Virtual Desktop?

368 views Asked by At

I run test program windows8 or 7 64/32bit

but i can't capture screen when running virtual desktop

here is my code

hwnd h1 = createwindows(....) or dialog.. //if this line remove capture code works fine

hDesktopCurrent = NULL;
hOriginalInput = NULL;
hDesktopCurrent = GetThreadDesktop(GetCurrentThreadId());
hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);

hDeskVirtual= NULL;

attr.nLength = sizeof(attr);
attr.lpSecurityDescriptor = NULL;
attr.bInheritHandle = true;

hDeskVirtual= CreateDesktopEx(
    "my_new_desktop_1",
    NULL,
    NULL,
    0,
    GENERIC_ALL,
    &attr,
    0,
    NULL);

SwitchDesktop(hDeskVirtual);
SetThreadDesktop(hDeskVirtual);

//capture here

SwitchDesktop(originaldesktop);
SetThreadDesktop(originaldesktop);

ps: When I nerver create any windows hwnd before switchdesktop (ex:createwindows,creatdialog...) it works perfertly capture..

but I create any windows frame or dialog, it didn't work that only captured BlackScreen

plz..help me!

0

There are 0 answers