I am creating new desktop from my C++ app and then switch to this desktop (by calling SetThreadDesktop
) to create explorer process there. Then switch back to original desktop. The first problem is that I can't see this desktop in TaskView. And the second (and most important) problem is that I can't launch several applications (Google Chrome for example) or even open Start menu by pressing start button, but can start notepad for example. However if I create new desktop from task view then everything works fine. So the question is how to create new desktop from C++ application that will allow to create all processes and open start menu?
Here is my code:
HDESK CreateDevTestDesktopW(const wchar_t* desktop_name)
{
wchar_t explorer_path[MAX_PATH];
HDESK original_desktop;
HDESK devtest_desktop = NULL;
STARTUPINFOW startup_info = { 0 };
PROCESS_INFORMATION process_info = { 0 };
ExpandEnvironmentStringsW(L"%windir%\\explorer.exe", explorer_path, MAX_PATH - 1);
devtest_desktop = CreateDesktopW(desktop_name, NULL, NULL, 0, GENERIC_ALL, NULL);
original_desktop = GetThreadDesktop(GetCurrentThreadId());
if (SetThreadDesktop(devtest_desktop))
{
startup_info.cb = sizeof(startup_info);
startup_info.lpDesktop = LPWSTR(desktop_name);
CreateProcessW(explorer_path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startup_info,
&process_info);
SetThreadDesktop(original_desktop);
}
return devtest_desktop;
}