Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using System.Runtime.InteropServices;
  5. namespace DrawTest {
  6. class Program {
  7.  
  8. [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
  9. static extern IntPtr GetDesktopWindow ();
  10.  
  11. [DllImport("User32.dll")]
  12. static extern IntPtr GetDC ( IntPtr hwnd );
  13.  
  14. [DllImport("User32.dll")]
  15. static extern void ReleaseDC ( IntPtr dc );
  16.  
  17. static void Main ( string[] args ) {
  18. while( true ) {
  19. IntPtr desktop = GetDC(GetDesktopWindow());
  20. using( Graphics g = Graphics.FromHdc(desktop) ) {
  21. g.FillRectangle(Brushes.White, 0, 0, 100, 100);
  22. System.Threading.Thread.Sleep(10);
  23. }
  24. ReleaseDC(desktop);
  25. }
  26. System.Console.ReadLine();
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement