

Static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam) Īnd you may want to declare the WM_CLOSE constant: const UInt32 WM_CLOSE = 0x0010 Static extern IntPtr FindWindowB圜aption(IntPtr ZeroOnly, string lpWindowName)

Using Pinvoke, you can try getting the handle for the actual window if you know what the window caption will be.įirst, import these functions: I shall appreciate any help/ ideas in finding a solution for this problem. But in this case I have absolutely no idea how to get rid of the icon (how to close minimized window) on the TaskPane. In such a case, we receive a minimized window on the TaskPane and an icon in the SystemTray. Process newProc = Process.Start("c:\\Users\\Dmytro\\AppData\\Local\\Viber\\Viber.exe") StartInfo.WindowStyle = ProcessWindowStyle.Minimized ProcessStartInfo startInfo = new ProcessStartInfo("c:\\Users\\Dmytro\\AppData\\Local\\Viber\\Viber.exe") There is also another way: to start Viber minimized at once: using System But the only thing I need is to close Viber main window and leave the process in the System Tray. Method Kill does not fit, because it kills all. Process newProc = Process.Start("c:\\Users\\Dmytro\\AppData\\Local\\Viber\\Viber.exe") Ĭonsole.WriteLine("New process has started") Ĭonsole.WriteLine("Process has finished") īut whatever I tried (Close, Dispose) - it does not work. So, I have written a few lines of code, but I found that it still couldn't close the window: using System All the time I should close this obsolete window manually.

Normally, when Viber is starting, it appears a Viber main window on desktop and an icon - in system tray. I want it to make start Viber minimized to tray only. Its main idea is to fix the lack of functionality in Viber for Windows.
