I want to hide/remove the game's taskbar icon without hiding the game window itself. Since Unity is not capable of this I have tried hiding the icon using WS_EX_TOOLWINDOW:
[C# Hiding an application from the taskbar][1], but had no luck.
[Here][2], it suggested that "-batchmode" can hide the taskbar icon, which is true but this command hides the window too.
----------
Achieving this should be possible since [here][3], using WS_EX_TOOLWINDOW someone was able to hide the icon so I am definitely doing something wrong. This is how my code looks like right now:
[DllImport("User32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("User32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_HIDE = 0x00;
private const int SW_SHOW = 0x05;
private const int GWL_EXSTYLE = -0x14;
private const int WS_EX_TOOLWINDOW = 0x0080;
void Start()
{
IntPtr pMainWindow = Process.GetProcessesByName("Game")[0].MainWindowHandle;
ShowWindow(pMainWindow, SW_HIDE);
SetWindowLong(pMainWindow, GWL_EXSTYLE, GetWindowLong(pMainWindow, GWL_EXSTYLE) | ~WS_EX_TOOLWINDOW);
ShowWindow(pMainWindow, SW_SHOW);
}
Just to be clear, I'm talking about this taskbar icon: ![alt text][4]
[1]: https://stackoverflow.com/questions/8243588/c-sharp-hiding-an-application-from-the-taskbar
[2]: https://answers.unity.com/questions/1314410/make-application-close-to-the-tray.html
[3]: https://stackoverflow.com/questions/52031400/place-an-applications-icon-into-system-tray
[4]: /storage/temp/159279-capture.png
↧