Advertisement
Guest User

shutdownbutton.cs

a guest
May 30th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2. using System.Runtime.InteropServices;
  3.  
  4. class Test
  5. {
  6.     public const int WM_CLOSE = 0x10;
  7.    
  8.     [DllImport("user32.dll", SetLastError = true)]
  9.     static extern IntPtr FindWindow(string className, string windowName);
  10.  
  11.     [DllImport("user32.dll", CharSet = CharSet.Auto)]
  12.     static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);
  13.    
  14.     public static void Main(string[] args)
  15.     {
  16.         IntPtr hwnd = FindWindow("progman", null);
  17.         SendMessage(hwnd, WM_CLOSE, 0, 0);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement