public static void DrawRectangle(int x, int y, int width, int height, int lineWidth, Color color) { IntPtr desk = BaseWin32Api.GetDesktopWindow(); IntPtr deskDC = BaseWin32Api.GetDCEx(desk, IntPtr.Zero, 0x403); BaseWin32Api.RedrawWindow(IntPtr.Zero, null, IntPtr.Zero, 0x85); using (Graphics g = Graphics.FromHdc(deskDC)) { //实例化Pen类 System.Drawing.Pen myPen = new System.Drawing.Pen(color, lineWidth); g.DrawRectangle(myPen, 0, 0, width - lineWidth, height - lineWidth); } //g.DrawString("Lightning", new Font("宋体", 50, FontStyle.Bold), Brushes.Red, new PointF(100, 100)); }