请相信我,我已经用 Google 搜索过它并希望它很容易找到 - 事实证明并非如此。 我有窗口句柄,但没有窗体。我该怎么做? 谢谢!
最佳答案
声明这些:
[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;
然后在显示表单之前使用它:
SetWindowLong(handle, GWL_EX_STYLE, (GetWindowLong(handle, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);
(将句柄更改为存储窗口句柄的任何内容)
关于c# - 使用 WinAPI 在 C# 中从任务栏隐藏窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3260757/