C# 如何拍摄完整桌面Windows c的屏幕截图#

C# 如何拍摄完整桌面Windows c的屏幕截图#,c#,c++,windows,msdn,C#,C++,Windows,Msdn,下面的代码仅拍摄桌面窗口的屏幕截图。我的期望是用任务栏截图和用户可以看到的一切 任何帮助都将不胜感激 ''' { ''这对你来说应该很好,重复问题 您必须将位图captureBitmap=新位图(1024768,PixelFormat.Format32bppArgb);更改为位图captureBitmap=新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,PixelFormat.Format32bpp

下面的代码仅拍摄桌面窗口的屏幕截图。我的期望是用任务栏截图和用户可以看到的一切

任何帮助都将不胜感激

''' {


''

这对你来说应该很好,重复问题


您必须将位图captureBitmap=新位图(1024768,PixelFormat.Format32bppArgb);更改为位图captureBitmap=新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,PixelFormat.Format32bppArgb);您的位图已被删除small@Triims,我也尝试了下面的代码。但我仍然没有得到任务栏var bmpScreenshot=新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,PixelFormat.Format32bppArgb);这很奇怪,我测试了它,通过更改那一行,它对我有效。是否在该位置创建了文件?毫无疑问。请阅读。
       //Creating a new Bitmap object

      Bitmap captureBitmap = new Bitmap(1024, 768, PixelFormat.Format32bppArgb);

   
     //Bitmap captureBitmap = new Bitmap(int width, int height, PixelFormat);

     //Creating a Rectangle object which will  

     //capture our Current Screen

     Rectangle captureRectangle = Screen.AllScreens[0].Bounds;



     //Creating a New Graphics Object

     Graphics captureGraphics = Graphics.FromImage(captureBitmap);



    //Copying Image from The Screen

    captureGraphics.CopyFromScreen(captureRectangle.Left,captureRectangle.Top,0,0,captureRectangle.Size);



    //Saving the Image File (I am here Saving it in My E drive).

    captureBitmap.Save(@"E:\Capture.jpg",ImageFormat.Jpeg);



    //Displaying the Successfull Result



    MessageBox.Show("Screen Captured");

}
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, 
                                    Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);