V
V
vladgovor777712017-08-17 23:53:49
.NET
vladgovor77771, 2017-08-17 23:53:49

Hide the graphical shell of the program?

Good afternoon,
The question arose, is it possible to start the process of the program without its graphical shell?
For example: run bittorent, the program works fully, distributes peers, that is, all functions, but without a graphical shell, only a process in the dispatcher.
I heard you can use .NET and class Process, but how exactly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Arxont, 2017-08-18
@arxont

static int hWnd = 0;

private const int SW_HIDE = 0;
private const int SW_SHOW = 5;

[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);

static void Main()
{
   Process proc = Process.Start("notepad");
   Console.WriteLine("Press any key"); Console.ReadKey();

   foreach (Process pr in Process.GetProcesses())
   {
      if (pr.ProcessName == "notepad")
      {
         hWnd = pr.MainWindowHandle.ToInt32();
         ShowWindow(hWnd, SW_HIDE);
      }
   }
   Console.WriteLine("Press any key"); Console.ReadKey();

   if (hWnd != 0)
   {
     ShowWindow(hWnd, SW_SHOW);
     hWnd = 0;
   }
   Console.WriteLine("Press any key"); Console.ReadKey();
}

A
aynur_safin, 2017-08-18
@aynur_safin

NSSM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question