How can I prevent windows from appearing in .NET?

I am currently working on an access control program in C # and I am faced with the problem of blocking windows. The initial idea that I came up with is the usual black shape above the position given by the handle to the IntPtr window of the process. The problem is that smoothly updating the position of the form and the z-index of the position (I do not want it to be at the top). I also noticed a ridiculously high use of resources with my solution, as I used a loop to constantly check the position.

So, why I ask: what would be the best solution for this, without having large resources? The entry point is simply the name of the running process.

Currently, the idea blocks only browsers (IE: a school application to prevent distraction during an active lecture).

Additional Information:

  • I do not want to close the window my own application, I try to hide hidden windows from other processes.

  • My application is not a virus / annoying program, it is mainly to prevent the use of potentially distracting applications in the school environment. He lectured on a school laboratory computer.

  • I am now pulling out the main window from the process, the process name of the browsers.

  • I can not completely turn off computers.

+3
source share
5 answers
   [DllImport("user32.dll")]
   static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); 

   static void MinimizeProcess(string procName)
    {
        foreach (Process p in Process.GetProcesses())
        {
            if (p.ProcessName == procName)
            {
                ShowWindow(p.MainWindowHandle,11);

            }
        }
    }

, , , , , , , .

+1

, . , .

, , - , , -, , .

, , .

+4

windows api, . user32.showwindow

Not what you requested, but it could be easier.

+1
source

You can do:

this.Hide()

this.Visible = false;

Or, if this is the main thing, you do not want to show, just do not start the forum when the application starts.

-2
source

Source: https://habr.com/ru/post/1754483/


All Articles