0

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

2
Contributors
1
Reply
3
Views
9 Years
Discussion Span
Last Post by FreakyEddie
0

When you're hiding the window you can't find it anymore on your controlbar... use other controls.. here's the full list:

private const int SW_HIDE = 0;
private const int SW_SHOWNORMAL = 1;
private const int SW_NORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;
private const int SW_SHOWMAXIMIZED = 3;
private const int SW_MAXIMIZE = 3;
private const int SW_SHOWNOACTIVATE = 4;
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6;
private const int SW_SHOWMINNOACTIVE = 7;
private const int SW_SHOWNA = 8;
private const int SW_RESTORE = 9;
private const int SW_SHOWDEFAULT = 10;
private const int SW_FORCEMINIMIZE = 11;
private const int SW_MAX = 11;

Hope this helps for you.

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.