title: Drawing on the Desktop using C#
body: <p>I'm trying to draw a rectangle right on the desktop using C#. After finding some solutions and I got these:</p>
  
  <pre><code>using System;
  using System.Drawing;
  using System.Runtime.InteropServices;
  using System.Windows.Forms;
  
  namespace Test
  {
      public partial class Form1 : Form
      {
          [DllImport("User32.dll")]
          public static extern IntPtr GetDC(IntPtr hwnd);
          [DllImport("User32.dll")]
  
          static extern int ReleaseDC(IntPtr hwnd, IntPtr dc);
          public Form1()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              myFunc();
          }
  
          public void myFunc()
          {
              IntPtr desktop = GetDC(IntPtr.Zero); 
              using (Graphics g = Graphics.FromHdc(desktop))
              {
                  g.FillRectangle(Brushes.Red, 0, 0, 100, 100);
              }
              ReleaseDC(IntPtr.Zero, desktop);
          }
      }
  }
  </code></pre>
  
  <p>But when I run it, I got nothing on my screen. Can anyone help me find out which part goes wrong? It would be much appreciated!</p>