windows 使用 C# 隐藏任务栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1344652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:03:19  来源:igfitidea点击:

Hide the taskbar using C#

c#windowssecuritykiosk

提问by Anuya

I am running Windows XP 64 bit. I want to hide the taskbar when I run my application.

我正在运行 Windows XP 64 位。我想在运行应用程序时隐藏任务栏。

I tried codes by searching the web. In all those, it hides the task bar. But the problem is, when i open a notepad and maximize it, it is not actually into full screen. Because the space where task bar was there is still blocked with empty space. I want it fit really into full screen mode.

我通过搜索网络尝试了代码。在所有这些中,它隐藏了任务栏。但问题是,当我打开记事本并将其最大化时,它实际上并没有进入全屏模式。因为任务栏所在的空间仍然被空白空间挡住了。我希望它真正适合全屏模式。

回答by Oliver

If you like to replace the windows shell (taskbar) you'll have to change a registry key.

如果您想更换 Windows 外壳(任务栏),则必须更改注册表项。

Changing the default shell (all users):

更改默认 shell(所有用户):

  1. open regedit (start menu > run, and type in regedit)
  2. go to: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.
  3. Change Shell from explorer.exe to your program path and name e.g. c:\myKioskApp\Kiosk.exe
  1. 打开regedit(开始菜单>运行,然后输入regedit)
  2. 转到:HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon。
  3. 将 Shell 从 explorer.exe 更改为您的程序路径和名称,例如 c:\myKioskApp\Kiosk.exe

Changing the default shell (only current user):

更改默认 shell(仅限当前用户):

  1. open regedit (start menu > run, and type in regedit).
  2. go to: HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon.
  3. add a new string value (Edit > New > String Value) called shell. and set the value to the path of the new shell e.g. c:\myKioskApp\Kiosk.exe
  4. log out and log back in.
  1. 打开 regedit(开始菜单 > 运行,然后输入 regedit)。
  2. 转到:HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon。
  3. 添加一个名为 shell 的新字符串值(编辑 > 新建 > 字符串值)。并将值设置为新 shell 的路径,例如 c:\myKioskApp\Kiosk.exe
  4. 注销并重新登录。

回答by Charlie Salts

I've done this by making the application borderless, maximized, and setting it to be Topmost. Here's a perfect examplefrom CodeProject.

我通过使应用程序无边界、最大化并将其设置为 Topmost 来完成此操作。这是来自 CodeProject的一个完美示例

As one of the commenters has said, replacingdisabling Explorer and running your application might be the best way, security-wise.

正如其中一位评论者所说, 替换禁用资源管理器并运行您的应用程序可能是安全方面的最佳方式。

回答by Pranav Labhe

You Can Hide your task bar by setting Following Properties of your C# Form.

您可以通过设置 C# 表单的以下属性来隐藏您的任务栏。

WindowState : Maximized FormBorderStyle : FixedDialog

WindowState : 最大化 FormBorderStyle : FixedDialog

回答by cieunteung

on window 7 (or maybe higher) using FormWindowState.Maximizedis wrong because the maximum size will be subtracted by Taskbar height but you can do this

在窗口 7(或更高)上使用FormWindowState.Maximized是错误的,因为最大尺寸将被任务栏高度减去,但您可以这样做

this.WindowState = FormWindowState.Normal; // or default
this.FormBorderStyle = FormBorderStyle.None;
this.TopMost = true;

// do it here
this.Location = new Point(0,0);
var fullscreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.Size = fullscreenSize;