using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TeamViwerHide
{
public partial class frmProcessOp : Form
{
public frmProcessOp()
{
InitializeComponent();
}
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
private void frmProcessOp_Load(object sender, EventArgs e)
{
Process[] proc = Process.GetProcesses();
List<ComboboxItem> items = new List<ComboboxItem>();
foreach (Process p in proc)
{
try
{
ComboboxItem item = new ComboboxItem();
item.Text = p.ProcessName + @"\" + p.Id + @"\" + p.SessionId;
item.Value = p.MainWindowHandle;
items.Add(item);
}
catch { continue; }
}
cmbProc.DataSource = items;
cmbProc.ValueMember = "Value";
cmbProc.DisplayMember = "Text";
cmbProc.SelectedIndex = 0;
cmbOptions.DataSource = Enum.GetValues(typeof(Options));
}
int handle = -1;
private void btnSet_Click(object sender, EventArgs e)
{
object obj = (int)Enum.Parse(typeof(Options), cmbOptions.SelectedValue.ToString());
try { ShowWindow(handle, (int)obj); } catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void cmbProc_SelectedIndexChanged(object sender, EventArgs e)
{
try {
handle = int.Parse(cmbProc.SelectedValue.ToString());
}
catch { }
}
}
public class ComboboxItem
{
public string Text { get; set; }
public Object Value { get; set; }
}
public enum Options
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10
}
}
Comments
Post a Comment