Doesn't work ShowWindow Run As Administrator

330 Views Asked by At

Iam writing a program for hide target program , actually its working but , when I run the program as administrator , showWindow function doesn't work.How can I solve this problem?

  private void button1_Click(object sender, EventArgs e)
   {       
            Process mbot = null;
            pHandle = IntPtr.Zero;

            foreach (var process in Process.GetProcesses())
            {
                if (process.ProcessName == "mBot_vSRO110")
                {
                    mbot = process;
                }

            }            
            pHandle = mbot.MainWindowHandle;
            Thread.Sleep(100);    
        }            

        ShowWindow(pHandle, 0);
    }
1

There are 1 best solutions below

2
On BEST ANSWER

This is due to User Interface Privilege Isolation. Because the window is in a higher privilege process, your call is ignored.

To control an elevated process, run your own process elevated.