使用WinAPI隐藏C#中任务栏的窗口

Laz*_*zlo 4 .net c# winapi taskbar window

相信我,我用谷歌搜索它并期望它是一个相当容易的发现 - 事实证明它不是.我有窗把手,但没有窗体.我该怎么做?谢谢!

Joe*_*ein 6

声明这些:

 [DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private const int GWL_EX_STYLE = -20;
private const int WS_EX_APPWINDOW = 0x00040000, WS_EX_TOOLWINDOW = 0x00000080;
Run Code Online (Sandbox Code Playgroud)

然后在显示表单之前使用它:


SetWindowLong(handle, GWL_EX_STYLE, (GetWindowLong(handle, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);
Run Code Online (Sandbox Code Playgroud)

(将句柄更改为存储窗口句柄的任何内容)