PaintDesktop (user32)
Last changed: Martin@Lehmann.ws-87.177.190.58

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool PaintDesktop(IntPtr hdc);

User-Defined Types:

None.

Notes:

Draws the desktop background to the provided device context.

Tips & Tricks:

Please add some!

Sample Code:

private void GrabDesktop()
{
     Graphics g=this.CreateGraphics(); //To Draw on the Main form
     IntPtr HDC=g.GetHdc(); //Get the Device context
     PaintDesktop(HDC); //Paint the form with the Desktop BackGround
     g.ReleaseHdc(HDC); //Release the Device Context
     g.Dispose();
}

private void Paint(object sender, PaintEventArgs e)
{
     IntPtr HDC = e.Graphics.GetHdc(); //Get the Device context
     PaintDesktop(HDC); //Paint the form with the Desktop BackGround
     e.Graphics.ReleaseHdc(HDC); //Release the Device Context
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation