简介 示范如何取得桌布的Handle并且利用DC在上面画图 范例代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace DrawDesktop { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IntPtr hdc = GetDCEx(GetDesktopWindow(), IntPtr.Zero, 1027); using (Graphics g = Graphics.FromHdc(hdc)) { g.FillEllipse(Brushes.Red, 0, 0, 400, 400); } } [DllImport("user32.dll")] static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll")] static extern IntPtr GetDCEx(IntPtr hwnd, IntPtr hrgn, uint flags); } }