问题描述
根据网络上得到的代码,进行截屏,截桌面和文件夹时,可以得到预计的图片,网页都可以,但是截取一些软件,例如系统自带的计算器等等得到的图片是全黑的,请问是和缘故?[code=csharp][/[DllImport("user32.dll")]publicstaticexternIntPtrGetWindowDC(IntPtrhwnd);publicBitmapGetWindow(IntPtrhWnd){IntPtrhscrdc=GetWindowDC(hWnd);varrect=Rectangle.Empty;varresult=GetWindowRect(hWnd,refrect);IntPtrhbitmap=CreateCompatibleBitmap(hscrdc,rect.Width,rect.Height);IntPtrhmemdc=CreateCompatibleDC(hscrdc);SelectObject(hmemdc,hbitmap);boolre=PrintWindow(hWnd,hmemdc,0);Bitmapbmp=newBitmap(rect.Width,rect.Height);if(re){bmp=Bitmap.FromHbitmap(hbitmap);}DeleteObject(hbitmap);DeleteDC(hmemdc);ReleaseDC(hWnd,hscrdc);returnbmp;}code]
时间: 2025-01-21 07:51:34