返回首页

介绍{S0的}
我一直在运行一段时间的Windows 8的开发人员预览版现在。由于我的笔记本电脑不支持触摸,我坚持用新的地铁风格开始菜单。老实说,这在触摸岩石!但我更喜欢经典的Windows 7开始菜单。
我上网一段时间在网上寻找一种方法来禁用新的地铁"开始"菜单和使用,而不是经典的Windows 7。许多网站指出,这是控制下HKEY_CURRENT_USER \ SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ Explorer中通过Windows注册表使用的RPEnabled的价值。地铁的价值是1,经典的Windows 7为0。
我决定编写的应用程序(称为"地铁风格切换??更新的RPEnabled注册表值。在这篇文章中,我将分享我如何读/写Windows注册表值之间切换的切换,以纾缓外壳风格。背景
要迅速总结了代码: 读的RPEnabled注册表值使用Microsoft.Win32.Registry.GetValue,反映在UI上的状态更新状态标签和禁用当前状态切换按钮。因此,举例来说,如果目前的状况是地铁,那么地铁的切换,应禁用。当用户切换的状态,我使用Microsoft.Win32.Registry.SetValue更新的RPEnabled的注册表值。因此,例如,如果用户想切换回地铁,然后RPEnabled应更新,成为1。警报显示给用户,要求他们重新启动他们的计算机以使更改生效。
我写的代码上运行的Windows 8开发人员预览版,我不知道,如果它可以运行在Beta或RTM的版本。此外,你必须以管理员身份运行此应用,否则将无法更新Windows注册表(它的工作与我没有管理权限的,也许是因为我的管理员{S1},更好地以管理员身份运行)。请注意,Windows可能会问你,如果你还没有激活运行时使用的Windows功能激活SP1的安装微软NET Framework 3.5中。地铁风格
{S2的}经典的Windows 7风格
{S3的}源代码
我解释的源代码是最简单的方式发表评论,并粘贴在这里。所以你在源代码感兴趣的爱好者,让我们开始挖掘:

using System;

using Microsoft.Win32; 

//Used for Registry.GetValue() and Registry.SetValue() - Lines 78 and 88

using System.Windows.Forms;

using System.Diagnostics; 

//Used for Process.Start() - Line 134



namespace MetroStyleToggle

{

    public partial class ToggleControl : Form

    {

        public ToggleControl()

        {

            InitializeComponent();

        }



        enum ShellStatus { Metro, Classic, Unknown }

        ShellStatus currentShellStatus;

        string registryPath = @"HKEY_CURRENT_USER\Software\Microsoft\

                                Windows\CurrentVersion\Explorer",

            registryValue = "RPEnabled";

        string metroStyle = "1", classicStyle = "0", currentKeyValue = "", 

            restartMessege = "Restart needed for updates to take effect.";



        private void ToggleControl_Load(object sender, EventArgs e)

        {

            SetShellStatusMessege();

        }



        private void SetShellStatusMessege()

        {

            //Get the current shell style state from Windows Registry and 

            // store it inside currentKeyValue

            //You will find more explanation about the GetRegistryValue function

            // whereabouts below

            currentKeyValue = GetRegistryValue(registryPath, registryValue);

            //Maintain the current shell style state

            SetShellStatus(currentKeyValue);

            //Update the shell status label with the current shell style state

            ShellStatusMessege.Text = currentShellStatus.ToString();

        }

        

        private void SetShellStatus(string status)

        {

            if (status == metroStyle)

            {

                //Set the shell style state to Metro

                currentShellStatus = ShellStatus.Metro;

                //Disable the MetroToggle button

                MetroToggle.Enabled = false;

                //Enable the ClassicToggle button

                ClassicToggle.Enabled = true;

            }

            else if (status == classicStyle)

            {

                //Set the shell style state to Classic

                currentShellStatus = ShellStatus.Classic;

                //Enable the MetroToggle button

                MetroToggle.Enabled = true;

                //Disable the ClassicToggle button

                ClassicToggle.Enabled = false;

            }

            else

            {

                //Set the shell style state to Unknown

                currentShellStatus = ShellStatus.Unknown;

            }

        }



        public string GetRegistryValue(string path, string value) 

        {

            //Return the Windows Registry value using the Path set in 

            // registryPath and registryValue

            //registryPath value is 

            // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer

            //registryValue value is RPEnabled

            //If the key does not exist, the return value will be "Unknown"

            return Convert.ToString(Registry.GetValue(path, value, "Unknown"));

        }



        public void SetRegistryValue(string path, string value, string shell)

        {

            //Write to Windows Registry using the 

            //Path set in registryPath and registryValue

            //registryPath value is 

            // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer

            //registryValue value is RPEnabled

            //shell contains either 0 for Classic Windows 7 Style or 1 for Metro Style

            Registry.SetValue(path, value, shell);

        }



        private void MetroToggle_Click(object sender, EventArgs e)

        {

            try

            {

                //Set the shell style state to Classic, classicStyle was set to 1

                SetRegistryValue(registryPath, registryValue, metroStyle);

                //Update the status label

                SetShellStatusMessege();

                //Alert the user to restart their machine

                MessageBox.Show(restartMessege,this.Text, 

                    MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }

            catch (Exception ex)

            {

                //Capture the error and push it to the status label

                ShellStatusMessege.Text = "Error: " + ex.Message;

            }

        }



        private void ClassicToggle_Click(object sender, EventArgs e)

        {

            try

            {

                //Set the shell style state to Classic, classicStyle was set to 0

                SetRegistryValue(registryPath, registryValue, classicStyle);

                //Update the status label

                SetShellStatusMessege();

                //Alert the user to restart their machine

                MessageBox.Show(restartMessege, this.Text, 

                    MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }

            catch (Exception ex)

            {

                //Capture the error and push it to the status label

                ShellStatusMessege.Text = "Error: " + ex.Message;

            }

        }



        private void BlogLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            //Launch the user's default browser and browse to my blog URL. 

            //BlogLink is a LinkButton and it's Text property 

            // is set to http://www.sharepointstack.com/

            Process.Start(BlogLink.Text);

        }

    }

}

嗯,就是这样。 的|班德尔Alsharfi最有价值球员]

回答

评论会员:游客 时间:2012/02/06
谢谢你的努力。我有建议。如果你杀了explorer.exe进程,并再次运行它。你的程序并不需要重新启动
ghostrider13
评论会员:游客 时间:2012/02/06
。类似的事情,但不依赖于NET或任何其他超出标准的WindowsDLLimgsrc=
JamesHollowell:我不能让胜8切换回地铁
我查了注册表,并进行了更新,但我重新启动Windows,它仍然是经典。 {五}

如果有人能帮助,这将是巨大的
评论会员:HansHank 时间:2012/02/06
得到地铁回来最快的方法是使用:{A2的}

笔者的MetroStyleToggle应该检查他的应用程序错误。
出生在阿拉斯加
野生汉斯・汉克
:robertw019 | |我看不出一点
评论会员:弗洛里安Rappl 时间:2012/02/06
{六}
,打捆Alsharfi
MVP时,SharePoint Server
{A3的}
评论会员:朱利安维莱 时间:2012/02/06
您的解决方案是在目前的救星 - 感谢