I found out that I can take a screenshot of an application using this method (and I'm currently taking a screenshot of my application and its working fine):
Bitmap image = new Bitmap(x, y, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(image);
IntPtr hDC = graphics.GetHdc();
SendMessage(this.Handle, WM_PRINT, hDC, PRF_CLIENT | PRF_CHILDREN | PRF_ERASEBKGND);
graphics.ReleaseHdc(hDC);
Unfortunately, this method stops working when I try to print the screen out, for example changing it to this:
Bitmap image = new Bitmap(x, y, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(image);
IntPtr hDC = graphics.GetHdc();
SendMessage(WIN32_API.GetDesktopWindow(), WM_PRINT, hDC, PRF_CLIENT | PRF_CHILDREN | PRF_ERASEBKGND);
graphics.ReleaseHdc(hDC);
Even when I try to get the process of my application and then use it's handler (Process.Handler), it's still not working although I can use (this.Handler). Why is this happening? and is there a way I can print out any process with this method (WM_PRINT)? I don't want to use other methods.