Beispiel #1
0
        //检查当前鼠标滚轮方向
        void CheckStats()
        {
            try {
                showlabel.Text = "";
                RegistryKey MouseKey;
                int         count = 1;
                //检索子项
                MouseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Enum\HID", false);
                //检索所有子项HID下项目
                foreach (string TreeA in MouseKey.GetSubKeyNames())
                {
                    RegistryKey TreeAkey = MouseKey.OpenSubKey(TreeA, false);
                    foreach (string TreeB in TreeAkey.GetSubKeyNames())
                    {
                        //打开TreeAkey的子项
                        RegistryKey TreeBkey = TreeAkey.OpenSubKey(TreeB, false);
                        //检索Service=mouhid
                        if (TreeBkey.GetValue("Service", "").Equals("mouhid"))
                        {
                            //打开TreeBkey的子项Device Parameters
                            RegistryKey TreeCkey = TreeAkey.OpenSubKey(TreeB + "\\Device Parameters", false);
                            if (TreeCkey.GetValue("FlipFlopWheel", RegistryValueKind.DWord) != null)
                            {
                                //读取FlipFlopWheel的值
                                Int32 TreeC = (Int32)TreeCkey.GetValue("FlipFlopWheel", RegistryValueKind.DWord);

                                CheckFlage(TreeC);

                                showlabel.Text += (FaceFlag + "  " + count + "\r\n");

                                count += 1;
                            }
                        }
                    }
                }
            } catch (Exception msg)
            {
                MessageBox.Show(msg.Message);
            }
        }
Beispiel #2
0
        void SetConfigReg()
        {
            try {
                showlabel.Text = "";
                WinFilePath    = AppDataPath + "\\WinStyle.reg";
                OSXFilePath    = AppDataPath + "\\OSXStyle.reg";
                if (!Directory.Exists(AppDataPath))
                {
                    Directory.CreateDirectory(AppDataPath);
                }
                if (File.Exists(WinFilePath))
                {
                    File.Delete(WinFilePath);
                }
                if (File.Exists(OSXFilePath))
                {
                    File.Delete(OSXFilePath);
                }
//

                RegistryKey MouseKey;
                string      HeadString;
                int         count = 1;
                //检索子项
                MouseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Enum\HID", false);
                //检索所有子项HID下项目
                foreach (string TreeA in MouseKey.GetSubKeyNames())
                {
                    RegistryKey TreeAkey = MouseKey.OpenSubKey(TreeA, false);
                    foreach (string TreeB in TreeAkey.GetSubKeyNames())
                    {
                        //打开TreeAkey的子项
                        RegistryKey TreeBkey = TreeAkey.OpenSubKey(TreeB, false);
                        //检索Service=mouhid
                        if (TreeBkey.GetValue("Service", "").Equals("mouhid"))
                        {
                            //打开TreeBkey的子项Device Parameters
                            RegistryKey TreeCkey = TreeAkey.OpenSubKey(TreeB + "\\Device Parameters", false);
                            if (TreeCkey.GetValue("FlipFlopWheel", RegistryValueKind.DWord) != null)
                            {
                                //读取FlipFlopWheel的值
                                Int32 TreeC = (Int32)TreeCkey.GetValue("FlipFlopWheel", RegistryValueKind.DWord);

                                CheckFlage(TreeC);
//				                logtext.AppendText("USB名称  " + TreeC + "\r\n");

                                String Path = "\\" + TreeA + "\\" + TreeB;
                                String Name = (string)TreeBkey.GetValue("DeviceDesc", "");

//				                logtext.AppendText(WinFilePath+"\r\n");
//				               logtext.AppendText(OSXFilePath+"\r\n");

                                showlabel.Text += ("M" + count + ": " + FaceFlag + "\r\n\r\n");

                                if (count == 1)
                                {
                                    HeadString = "Windows Registry Editor Version 5.00\r\n";
                                    WriteReg(WinFilePath, HeadString);
                                    WriteReg(OSXFilePath, HeadString);
                                }

                                WinString = "[" + MouseKey + Path + "\\Device Parameters]" + "\r\n" + "\"FlipFlopWheel\"=dword:00000000\r\n";

//				                logtext.AppendText(WriteString);
                                WriteReg(WinFilePath, WinString);

                                OSXString = "[" + MouseKey + Path + "\\Device Parameters]" + "\r\n" + "\"FlipFlopWheel\"=dword:00000001\r\n";
                                WriteReg(OSXFilePath, OSXString);
                                count += 1;
                            }
                        }
                    }
                }
            } catch (Exception msg)
            {
                MessageBox.Show(msg.Message);
            }
        }