I have already gone through articles in stack overflow related to virtual desktops, below are the links related to virtual desktop but it doesn't resolve my issue.
"How to Switch a Process between Default Desktop and Winlogon Desktop?" How to switch a process between default desktop and Winlogon desktop?
"Moving applications between desktops in Windows" Moving applications between desktops in Windows
I have WPF application running on one desktop and I want to move that application to another desktop when I switch to that desktop. I already applied the code mentioned in of the articles as mentioned below.
{code}
Debug.Write("MoveTONewDesktop ........");
IntPtr hWinSta0 = OpenWindowStation("WinSta0", false, ACCESS_MASK.MAXIMUM_ALLOWED);
Debug.Write("Windows Station Pointer "+ hWinSta0.ToInt32());
if (null == hWinSta0) { }
hWinSta0 = SetProcessWindowStation(hWinSta0);
Debug.Write("SetProcessWindowStation " + hWinSta0.ToInt32());
IntPtr hDesk = OpenDesktop("ABCD", 0, false, ACCESS_MASK.MAXIMUM_ALLOWED);
Debug.Write("OpenDesktop " + hDesk.ToInt32());
if (null == hDesk) { }
bool result = SwitchDesktop(hDesk);
Debug.Write("SwitchDesktop " + result);
bool bSuccess = SetThreadDesktop(hDesk);
Debug.Write("SetThreadDesktop " + bSuccess);
if (!bSuccess)
{
Debug.Write("Get Last WIn32 Error " + Marshal.GetLastWin32Error());
System.Console.WriteLine(Marshal.GetLastWin32Error());
}
if (hDesk != null) { CloseDesktop(hDesk); }
if (hWinSta0 != null) { CloseWindowStation(hWinSta0); }
On debugging I see correct handle get printed and my desktop get switched. Also setThreadDesktop shows true value but my application remains in old desktop and doesn't move to new desktop. What could be th reason that my application doesnt move from one desktop to another. Am I missing something. Please help...
Thanks & Regards, Ashu