I have this code:
#define _WIN32_WINNT 0x0500
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
Sleep(500);
HDESK hOriginalThread;
HDESK hOriginalInput;
hOriginalThread = GetThreadDesktop(GetCurrentThreadId());
hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
HDESK hNewDesktop=CreateDesktop("Test",NULL,NULL,0,DELETE|READ_CONTROL|WRITE_DAC|WRITE_OWNER|GENERIC_ALL,NULL);
cout<<SetThreadDesktop(hNewDesktop);
Sleep(575);
SwitchDesktop(hNewDesktop);
system("cmd");
Sleep(1000);
SwitchDesktop(hOriginalInput);
SetThreadDesktop(hOriginalThread);
CloseDesktop(hNewDesktop);
CloseDesktop(hOriginalInput);
Sleep(1000);
return 0;
}
When I run this, it creates new desktop, switch to it, but command prompt not appeared. I must manualy terminate process "cmd" and my program then continue. Is there a way to show window of any application on other desktop? And how I can change background of desktop I created? Please help.