I'm trying to make a program that can hide a process that is running, and then restore it for you.
I can successfully Hide the window using
private const int SW_HIDE = 0;
private const int SW_RESTORE = 9;
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
private void btnLogonServerHide_Click(object sender, EventArgs e)
{
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
{
if (pr.ProcessName == "logonserver")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
}
}
But when i try
private void btnLogonServerShow_Click(object sender, EventArgs e)
{
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
{
if (pr.ProcessName == "logonserver")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_RESTORE);
}
}
}
It doesn't do anything.
Any help would be appreciated!
Thanks,
Sipex