C#中使用 桌面Graphics画图

首先要通过WINDOWS API获取HDC

IntPtr hDCDesktop = User32.GetWindowDC(User32.GetDesktopWindow());

然后通过Graphics g = Graphics.FromHdc(hDCDesktop);创建Graphics,这样才会有效。

如果直接通过桌面句柄创建出来的画图会有问题。。

原文地址:https://www.cnblogs.com/linweifu/p/1959422.html