加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 01:37:02 所属栏目:百科 来源:网络整理
导读:相信我,我用谷歌搜索它并期望它是一个相当容易的发现 – 事实证明它不是. 我有窗把手,但没有窗体.我该怎么做? 谢谢! 解决方法 声明这些: [DllImport("user32.dll",SetLastError = true)]static extern int GetWindowLong(IntPtr hWnd,int nIndex);[DllImp
相信我,我用谷歌搜索它并期望它是一个相当容易的发现 – 事实证明它不是.
我有窗把手,但没有窗体.我该怎么做?
谢谢!

解决方法

声明这些:

[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);

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读