There has been plenty written about replacing the Explorer Shell to disable the taskbar, but what if you want the Explorer Shell, but don’t want the taskbar?  This article will show how to disable the taskbar at runtime from your application.

I have tested this on Windows XP and Windows 7, both embedded and non-embedded.

So there are some things that we need to do, and some that are optional:

1.      Hide the taskbar.   This just makes it less visible while the system boots before you disable it from your application.

2.      Unlock the taskbar, which allows it to be hidden and disabled.

3.      Disable hot keys.   While the taskbar can be disabled, there are problems, like the Windows key will show the Start menu in Windows 7.  So if we disable some taskbar related keys we can avoid the problems.

4.      Disable the taskbar.  From an application, hide and disable the taskbar.

 

First, hide the taskbar.  I did a lot of research on this one and found that everybody who knew said something about changing Settings in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2 in the registry.   What I found was that this registry value is written to the registry when Explorer shuts down.  So, any changes that you need to make must be made either using Explorer or while Explorer is shut down.

StuckRects2 is a REG_BINARY value, which means that it is a long set of hex values.   Through some research and some trial and error, I found that the 9th byte effects the taskbar auto hide feature.   A value of 02 disables auto hide, and a value of 03 enables auto hide.

So for me, the following enabled auto hide:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2]
     "Settings"=hex:28,00,00,00,ff,ff,ff,ff,03,03,00,00,03,00,00,00,3e,00,00,00,28,\
      00,00,00,00,00,00,00,d8,03,00,00,00,03,00,00,00,04,00,00

Because all of the other values probably do something, you should use this with caution.

But of course, changing the registry won’t do anything if Explorer is still running, so I wrote the following batch file to handle that, where RegistryUpdate.reg contains  the new settings:

@echo off

REM need to kill explorer and restart for auto hide
REM task bar to take effect
REM so
REM kill explorer
cmd /c taskkill /F /IM explorer.exe

REM Insert registry changes
regedit /s RegistryUpdate.reg

REM Start explorer (Start tells it to run, but not to wait)
start explorer.exe

 

Second, unlock the taskbar.  This one is fairly simple, just add the following to RegistryUpdate.reg (mentioned above):

;Unlock the Taskbar so that it can be hidden from applications
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
     "TaskbarSizeMove"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
     "TaskbarSizeMove"=

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
     "LockTaskbar"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
     "LockTaskbar"=-

 

Third, disable hot keys.   This is fairly simple, but may need more explanation.  The value “Scancode Map” under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout controls disabling of hot keys.   This value is documented on MSDN at http://msdn.microsoft.com/en-us/library/windows/hardware/jj128267(v=vs.85).aspx so I won’t go into all of the details.  The following disables keys that I wanted disabled:

;Disable Windows and other hotkeys
;5b e0 LEft Windows Key
;5c e0 Right Windows Key
;5d e0 Windows Menu Key
;44 00 F10
;1d 00 Left Ctrl
;38 00 Left Alt 
;1d e0 Right Ctrl
;38 e0 Right Alt

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,09,00,00,00,00,00,5b,e0,00,00,5c,e0,00,00,5d,e0,00,00,\
               44,00,00,00,1d,00,00,00,38,00,00,00,1d,e0,00,00,38,e0,00,00,00,00

Finally, disable the taskbar.   This is fairly simple, we need to find a handle to taskbar, then hide the window (different from auto hide) and disable the window.   If we disable it but don’t hide it, it will still be visible.   If we hide it but don’t disable it, it might come back.

In C++, the code looks like this:

void CWin7FullScreenApp::ShowTaskBar( bool Show )
{
               HWND TaskBar = FindWindow(TEXT("Shell_traywnd"), NULL );
               if( TaskBar != NULL )
               {
                              DWORD SWShow = Show ? SW_SHOW : SW_HIDE;
                              ShowWindow( TaskBar, SWShow );
                              EnableWindow( TaskBar, Show );
               }
}

If ShowTaskBar is called with false, the taskbar is hidden.  So, as a test I hide the taskbar when my app starts, and show it when the destructor is called:

CWin7FullScreenApp::CWin7FullScreenApp()
{
               ShowTaskBar( FALSE );
}

CWin7FullScreenApp::~CWin7FullScreenApp()
{
               ShowTaskBar( TRUE );
}

But you may be using C#.   I am leaving out the P\Invokes because they are readily available at pinvoke.net.  The P\Invokes that I used are for ShowWindowCommands, FindWindow, ShowWindow and EnableWindow.

The code is:

public Win7FullScreen()
{
            InitializeComponent();
            ShowTaskBar(false);
}

 

void ShowTaskBar( bool Show )
{
            ShowWindowCommands SWShow = Show ? ShowWindowCommands.Show : ShowWindowCommands.Hide;
            IntPtr hStartBtn = FindWindow("Button", "Start");

                       IntPtr TaskBar = FindWindow("Shell_traywnd", null );
                       if( TaskBar != null )
                       {
                                      ShowWindow( TaskBar, SWShow );
                              EnableWindow( TaskBar, Show );
                       }
         }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            ShowTaskBar(true);
        }