Multi Desktop app, Need to take Screen short of a given desktop using handle.
-
I was been working on multiple desktop app. and would like to Screen shot of a desktop using the handle of the specific desktop.. I was using the blow code, but this always makes the the screenshort of current desktop.. as the Handle of "MyNewDesktop" was not supplyed. could you please tell me how to make use of hdesk to capture the screen short of the "MyNewDesktop". The below code is of utility app which captures desk top
hwinsta = OpenWindowStation("WinSta0", false, WINDOWS_STATION_ACCESS_MASK.WINSTA_ALL_ACCESS);
hwinsta2 = SetProcessWindowStation(hwinsta);
hdesk = OpenDesktop("MyNewDesktop", 0, false, DESKTOP_ACCESS_MASK.GENERIC_ALL);//0x0001L | SetThreadDesktop);
bool thset = SetThreadDesktop(hdesk);EnumDelegate delEnumfunc = new EnumDelegate(EnumWindowsProc); IntPtr DesktopWindow = GetDesktopWindow(); bool bSuccessful = EnumDesktopWindows(hdesk, delEnumfunc, DesktopWindow); if (bSuccessful) // this was sucessfull control enters this block { string filename = string.Format("ScreenCap-{0:yyyy-MM-dd\_hh-mm-ss-tt}", DateTime.Now); var bounds = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } bitmap.Save(@"C:\\" + filename + ".jpg", ImageFormat.Jpeg); } } else { // Get the last Win32 error code int nErrorCode = Marshal.GetLastWin32Error(); string strErrMsg = String.Format("EnumDesktopWindows failed with code {0}.", nErrorCode); throw new Exception(strErrMsg); }
thanks
-
I was been working on multiple desktop app. and would like to Screen shot of a desktop using the handle of the specific desktop.. I was using the blow code, but this always makes the the screenshort of current desktop.. as the Handle of "MyNewDesktop" was not supplyed. could you please tell me how to make use of hdesk to capture the screen short of the "MyNewDesktop". The below code is of utility app which captures desk top
hwinsta = OpenWindowStation("WinSta0", false, WINDOWS_STATION_ACCESS_MASK.WINSTA_ALL_ACCESS);
hwinsta2 = SetProcessWindowStation(hwinsta);
hdesk = OpenDesktop("MyNewDesktop", 0, false, DESKTOP_ACCESS_MASK.GENERIC_ALL);//0x0001L | SetThreadDesktop);
bool thset = SetThreadDesktop(hdesk);EnumDelegate delEnumfunc = new EnumDelegate(EnumWindowsProc); IntPtr DesktopWindow = GetDesktopWindow(); bool bSuccessful = EnumDesktopWindows(hdesk, delEnumfunc, DesktopWindow); if (bSuccessful) // this was sucessfull control enters this block { string filename = string.Format("ScreenCap-{0:yyyy-MM-dd\_hh-mm-ss-tt}", DateTime.Now); var bounds = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } bitmap.Save(@"C:\\" + filename + ".jpg", ImageFormat.Jpeg); } } else { // Get the last Win32 error code int nErrorCode = Marshal.GetLastWin32Error(); string strErrMsg = String.Format("EnumDesktopWindows failed with code {0}.", nErrorCode); throw new Exception(strErrMsg); }
thanks
Just to clarify, you are expecting to run a utility on YOUR machine and capture the image of someone else desktop? I would think you would need to deploy your utility on the target desktop, have it take the screenshot and send it to your app.
Never underestimate the power of human stupidity RAH
-
Just to clarify, you are expecting to run a utility on YOUR machine and capture the image of someone else desktop? I would think you would need to deploy your utility on the target desktop, have it take the screenshot and send it to your app.
Never underestimate the power of human stupidity RAH
No, it is windowsstation.. on the same PC you will have different desktop ie.. you can created and access
-
I was been working on multiple desktop app. and would like to Screen shot of a desktop using the handle of the specific desktop.. I was using the blow code, but this always makes the the screenshort of current desktop.. as the Handle of "MyNewDesktop" was not supplyed. could you please tell me how to make use of hdesk to capture the screen short of the "MyNewDesktop". The below code is of utility app which captures desk top
hwinsta = OpenWindowStation("WinSta0", false, WINDOWS_STATION_ACCESS_MASK.WINSTA_ALL_ACCESS);
hwinsta2 = SetProcessWindowStation(hwinsta);
hdesk = OpenDesktop("MyNewDesktop", 0, false, DESKTOP_ACCESS_MASK.GENERIC_ALL);//0x0001L | SetThreadDesktop);
bool thset = SetThreadDesktop(hdesk);EnumDelegate delEnumfunc = new EnumDelegate(EnumWindowsProc); IntPtr DesktopWindow = GetDesktopWindow(); bool bSuccessful = EnumDesktopWindows(hdesk, delEnumfunc, DesktopWindow); if (bSuccessful) // this was sucessfull control enters this block { string filename = string.Format("ScreenCap-{0:yyyy-MM-dd\_hh-mm-ss-tt}", DateTime.Now); var bounds = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } bitmap.Save(@"C:\\" + filename + ".jpg", ImageFormat.Jpeg); } } else { // Get the last Win32 error code int nErrorCode = Marshal.GetLastWin32Error(); string strErrMsg = String.Format("EnumDesktopWindows failed with code {0}.", nErrorCode); throw new Exception(strErrMsg); }
thanks
EnumDelegate delEnumfunc = new EnumDelegate(EnumWindowsProc); IntPtr DesktopWindow = GetDesktopWindow(); bool bSuccessful = EnumDesktopWindows(hdesk, delEnumfunc, DesktopWindow);
And? What does the delegate do?
var bounds = Screen.GetBounds(Point.Empty);
Well, that Screen is the main screen, isn't it?
-
EnumDelegate delEnumfunc = new EnumDelegate(EnumWindowsProc); IntPtr DesktopWindow = GetDesktopWindow(); bool bSuccessful = EnumDesktopWindows(hdesk, delEnumfunc, DesktopWindow);
And? What does the delegate do?
var bounds = Screen.GetBounds(Point.Empty);
Well, that Screen is the main screen, isn't it?
Thanks for response, Yes screen is the main screen, But how to capture the Screenshort of it... pls suggest