2

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!

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
user3451580
  • 31
  • 1
  • 5
  • [The `SetThreadDesktop` function will fail if the calling thread has any windows or hooks on its current desktop](http://msdn.microsoft.com/en-us/library/windows/desktop/ms686250%28v=vs.85%29.aspx). – arx Nov 27 '14 at 13:08

0 Answers0