How to disable the Windows 8 Charms bar programmat

2020-06-22 10:08发布

I need to create an application that will run full-screen on Windows 8 and which the user shouldn't be able to exit easily.

Since the application will be running on computers or tablets with only tactile input, I was going to create a chromeless and top-most WPF application, which could only be closed if a keyboard is connected.

The problem is that the app switching bar on the left and the charms bar on the right can still be opened without a keyboard and would allow users to exit the application. Can this be disabled from code? I can't seem to find a way.

The easy solution would be to run on another OS, but the machines will be running Windows 8 and there's not much I can do about that.

7条回答
对你真心纯属浪费
2楼-- · 2020-06-22 10:28

Kill explorer.exe when your application launches and charms bar won't work.

查看更多
我想做一个坏孩纸
3楼-- · 2020-06-22 10:30

The year is 2018 and Window 10 almost completely pushed out Windows 8. Win8's "hot corners" are again cold in Win10 - they were obviously a great success. But if you still need to disable them in Win8.x/Win2012 and end up here searching for a solution (as I did), here's how I solved it. I realised that Windows disables them automatically if a full-screen application is active and covering the task-bar. Since my application is dialog-based and not full-screen, I create a transparent window (transparent optically and transparent for input) and set it as the parent window for my dialog. Now this invisible window covers the whole screen -> hot corners are disabled.

Something like this (simplified):

int nVirtualScreenLeft   = GetSystemMetrics (SM_XVIRTUALSCREEN);
int nVirtualScreenTop    = GetSystemMetrics (SM_YVIRTUALSCREEN);
int nVirtualScreenWidth  = GetSystemMetrics (SM_CXVIRTUALSCREEN);
int nVirtualScreenHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);

HWND hwndFullScreenInvisible = CreateWindowEx(
    WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW,
    _T("Static"), strWindowCaption,
    WS_VISIBLE | WS_POPUP,
    nVirtualScreenLeft, nVirtualScreenTop, nVirtualScreenWidth, nVirtualScreenHeight,
    HWND_DESKTOP, NULL, NULL, NULL);

if (hwndFullScreenInvisible != NULL)
{
    BOOL bRet = SetLayeredWindowAttributes (hwndFullScreenInvisible, /*COLORREF = */ 0, /* byAlpha = */ 0, LWA_ALPHA);
}

CMyDlg dlg (CWnd::FromHandle(hwndFullScreenInvisible));
dlg.DoModal ();
查看更多
兄弟一词,经得起流年.
4楼-- · 2020-06-22 10:31

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell\EdgeUI\DisableTLcorner DWORD=1

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell\EdgeUI\DisableCharmsHint DWORD=1

查看更多
Evening l夕情丶
5楼-- · 2020-06-22 10:36

I know it might be a bit late to answer this question but hopefully this helps someone else, in your Regedit there is a regkey that allows you to choose what 'Shell' windows boots into, by default it is set to explorer.exe if you change this it will boot into whatever program that you would like without going through the stupid windows 8 start menu.

Regkey is at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\shell

Hope that helps you all.

查看更多
孤傲高冷的网名
6楼-- · 2020-06-22 10:39

I have dug up a .TXT with some notes I found somewhere on the net some time ago, it might be helpful (worst case scenario, it doesn't apply to Windows 8 and doesn't work. Unfortunately I'm unable to cite a source for it, I don't really remember where it came from):

A “kiosk mode” has already existed since XP. Usually it's aimed at locking IE up in order to show some interactive webpage while not letting the user close it: it's called mandatory user profiles.

To set it up:

  1. Set up the account just the way you want. Set the group policy, set up the startup programs The user must be a standard user, not an admin. But then again, if an unauthorized person can get admin rights even though the computer is “frozen”, I think you got more serious problems.
  2. Login as admin and Computer Properties > Advanced > User Profiles Settings > (select that profile) > (copy it to whatever place) > set “permitted to use” to Everyone
  3. Go to that folder properties > Security > (change it so that Everyone can read and modify, but not write, make sure you apply to EVERYTHING inside)
  4. Rename NTUSER.DAT to NTUSER.MAN
  5. Open Computer Management > Local Users and Groups > Users > (create a new user) > (open that newly created user) > Profile > (on profile path, set it to that folder)
  6. Disable the user that you just copied (since you don’t want people to login to there)

When you’re finished and log in the new account, you will find out it performs almost like kiosk mode that you have been seeking for. To undo changes, log off and log back in.

查看更多
在下西门庆
7楼-- · 2020-06-22 10:42

Simple solution, not perfect but works, every time the charms bar is activate, your application is deactivate, so reactivate it immediately and the charms bar disappear. add this in your App.xaml.cs

DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
    public App()
    {
        this.Deactivated += App_Deactivated;
        this.Activated += App_Activated;
        timer.Tick += delegate
        {
            Application.Current.MainWindow.Activate();
        };
        timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
    }

    void App_Activated(object sender, EventArgs e)
    {
        timer.Stop();
    }

    void App_Deactivated(object sender, EventArgs e)
    {
        timer.Start();
    }
查看更多
登录 后发表回答