Make any image gray style



public static Bitmap MakeGrayscale(Bitmap original)
{
  //make an empty bitmap the same size as original
  Bitmap newBitmap = new Bitmap(original.Width, original.Height);
  for (int i = 0; i < original.Width; i++)
  {
      for (int j = 0; j < original.Height; j++)
      {
          //get the pixel from the original image
          Color originalColor = original.GetPixel(i, j);
          //create the grayscale version of the pixel
          int grayScale = (int)((originalColor.R * .3) + (originalColor.G * .59)
              + (originalColor.B * .11));
          //create the color object
          Color newColor = Color.FromArgb(grayScale, grayScale, grayScale);
          //set the new image's pixel to the grayscale version
          newBitmap.SetPixel(i, j, newColor);
      }
  }
  return newBitmap;
}

Get Image of Open Form



//necessary function to create bitmap of form
        [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern IntPtr GetDC(IntPtr hWnd);
        [DllImport("user32.dll", ExactSpelling = true)]
        public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
        [DllImport("gdi32.dll", ExactSpelling = true)]
        public static extern IntPtr BitBlt(IntPtr hDestDC, int x, int y,
             int nWidth, int nHeight, IntPtr hSrcDC,
             int xSrc, int ySrc, int dwRop);
        public static Bitmap GetFormImage(System.Windows.Forms.Form frm)
        {
            Graphics g = frm.CreateGraphics();
            Size s = frm.Size;
            Bitmap formImage = new Bitmap(s.Width, s.Height, g);
            Graphics mg = Graphics.FromImage(formImage);
            IntPtr dc1 = g.GetHdc();
            IntPtr dc2 = mg.GetHdc();
            BitBlt(dc2, 0, 0, frm.ClientRectangle.Width, frm.ClientRectangle.Height, dc1, 0, 0, 13369376);
            g.ReleaseHdc(dc1);
            mg.ReleaseHdc(dc2);
            return formImage;
        }

Form Key Press Event



protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if (keyData == Keys.Control)
    {
        MessageBox.Show("The A key was pressed");
        return true;
    }
    return base.ProcessCmdKey(ref msg, keyData);
}

C# Image to Byte Array and Byte Array to Image Converter Class



public Image byteArrayToImage(byte[] byteArrayIn)
{
    MemoryStream ms = new MemoryStream(byteArrayIn);
    Image returnImage = Image.FromStream(ms);
    return returnImage;
}

Image to Byte Array and Byte Array to Image Converter Class




public byte[] imageToByteArray(System.Drawing.Image imageIn)

{

    MemoryStream ms = new MemoryStream();

    imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);

    return ms.ToArray();

}

Get associated icon from file



public enum IconSize
{
    Small,
    Large
}
public class IconExtractor
{
    private const uint SHGFI_ICON = 0x100;
    private const uint SHGFI_LARGEICON = 0x0;
    private const uint SHGFI_SMALLICON = 0x1;
    [StructLayout(LayoutKind.Sequential)]
    private struct SHFILEINFO
    {
        public IntPtr hIcon;
        public IntPtr iIcon;
        public uint dwAttributes;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
        public string szDisplayName;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
        public string szTypeName;
    };
    [DllImport("shell32.dll")]
    private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
    public IconExtractor()
    {
    }
    public System.Drawing.Icon Extract(string File, IconSize Size)
    {
        IntPtr hIcon;
        SHFILEINFO shinfo = new SHFILEINFO();
        if (Size == IconSize.Large)
        {
            hIcon = SHGetFileInfo(File, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON);
        }
        else
        {
            hIcon = SHGetFileInfo(File, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);
        }
        return System.Drawing.Icon.FromHandle(shinfo.hIcon);
    }
    public System.Drawing.Icon Extract(string File)
    {
        return this.Extract(File, IconSize.Small);
    }
}

GET COMPUTER NAME



public List GetComputersOnNetwork()
{
    List list = new List();
    using (DirectoryEntry root = new DirectoryEntry("WinNT:"))
    {
        foreach (DirectoryEntry computers in root.Children)
        {
            foreach (DirectoryEntry computer in computers.Children)
            {
                if ((computer.Name != "Schema"))
                {
                    list.Add(computer.Name);
                    comboBox1.Items.Add(computer.Name );
                }
            }
        }
    }
    return list;
}