コード例 #1
0
 public frmSettings()
 {
     InitializeComponent();
     Text = GlobalMessages.SETTINGS;
     //label_CloseToTray.Text = GlobalMessages.CLOSE_TO_TRAY;
     //groupBox_TrayMenuSetting.Text = GlobalMessages.TRAY_MENU_SETTING;
     //listView_TrayMenuSetting.Items.Clear();
     //listView_TrayMenuSetting.Columns[0].Text = GlobalMessages.TRAY_MENU_PRESETNAME;
     //listView_TrayMenuSetting.Columns[1].Text = GlobalMessages.TRAY_MENU_PRESETMODE;
     //listView_TrayMenuSetting.Columns[2].Text = GlobalMessages.TRAY_MENU_PRESETFILE;
     //singleButton_AddNewItem.ButtonText = GlobalMessages.ADD_NEW_ITEM;
     singleButton_OK.Text              = GlobalMessages.OK;
     singleButton_Cancel.Text          = GlobalMessages.CANCEL;
     toolStripMenuItem_RemoveItem.Text = GlobalMessages.REMOVE_ITEM;
     toolStripMenuItem_Name.Text       = GlobalMessages.MENU_TIPS_NAME;
     toolStripMenuItem_Mode.Text       = GlobalMessages.MENU_TIPS_MODE;
     toolStripMenuItem_Preset.Text     = GlobalMessages.SELECT_PRESET_FILE;
     toolStripComboBox_Mode.Items.Clear();
     toolStripComboBox_Mode.Items.Add(new frmSettings.PresetModeItem(0));
     toolStripComboBox_Mode.Items.Add(new frmSettings.PresetModeItem(1));
     toolStripComboBox_Mode.Items.Add(new frmSettings.PresetModeItem(2));
     m_lstTrayMenuPreset.Clear();
     m_bCloseToTray = false;
     //onOffSwitch_CloseToTray.SwitchedOn = false;
     label_EnableCoexist.Text = GlobalMessages.ENABLE_APO_COEXIST;
     if (RegHelper.QueryDWORD("LoadChildAPO", 0U) == 1U)
     {
         onOffSwitch_EnableCoexist.SwitchedOn = true;
     }
     else
     {
         onOffSwitch_EnableCoexist.SwitchedOn = false;
     }
 }
コード例 #2
0
        public static uint QueryDWORD(string szKeyName, uint uiDefault)
        {
            byte[] destination = new byte[Marshal.SizeOf(typeof(uint))];
            IntPtr num1        = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint)));
            int    num2        = RegHelper.QueryRegistryDWORDValue("SOFTWARE\\ViPER4Windows", szKeyName, num1);

            Marshal.Copy(num1, destination, 0, Marshal.SizeOf(typeof(uint)));
            Marshal.FreeHGlobal(num1);
            uint num3 = BitConverter.ToUInt32(destination, 0);

            if (num2 == 0)
            {
                num3 = uiDefault;
            }

            return(num3);
        }
コード例 #3
0
        public static string GetConfigFile()
        {
            int nBufferSize = 260;

            char[] destination = new char[nBufferSize * 2];
            IntPtr num1        = Marshal.AllocHGlobal(nBufferSize * 2);
            int    num2        = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigFile", num1, nBufferSize);

            Marshal.Copy(num1, destination, 0, nBufferSize * 2);
            Marshal.FreeHGlobal(num1);
            if (num2 == 0)
            {
                return("");
            }

            string str1 = new string(destination);

            if (string.IsNullOrEmpty(str1))
            {
                return("");
            }

            char[] charArray = str1.ToCharArray();
            int    length    = -1;

            for (int index = 0; index < charArray.Length; ++index)
            {
                if (charArray[index] == char.MinValue)
                {
                    length = index;
                    break;
                }
            }
            if (length == -1)
            {
                return("");
            }

            char[] chArray = new char[length];
            Array.Copy(charArray, chArray, length);
            string str2 = new string(chArray);

            return(string.IsNullOrEmpty(str2) ? "" : str2);
        }
コード例 #4
0
        private static void Main(string[] szArgs)
        {
            // new Thread(gc_).Start();
            if (Program.RunningInstance() != null)
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string szLanguagePath = "";
            string szLanguageFile = "";
            string baseDirectory  = AppDomain.CurrentDomain.BaseDirectory;

            if (!baseDirectory.EndsWith("\\"))
            {
                baseDirectory += "\\";
            }

            string szFolder = baseDirectory + "Language\\";
            string str1     = new ConfigFile(baseDirectory + "Config.ini").ReadConfig("$LANGUAGE_NAME");

            if (str1 == "")
            {
                str1 = "English";
            }

            string[] strArray = new FolderExplorer().ListFiles(szFolder);
            string   str2     = "";

            foreach (string szConfigPath in strArray)
            {
                if (new ConfigFile(szConfigPath).ReadConfig("$LANGUAGE_NAME").Trim() == str1)
                {
                    str2 = szConfigPath;
                    break;
                }
            }
            if (str2 != "")
            {
                szLanguagePath = szFolder;
                szLanguageFile = str2;
            }
            else if (str1 == "English")
            {
                int num1 = (int)MessageBox.Show("Can not load default language (English), use built-in language.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                string str3 = "English";
                foreach (string szConfigPath in strArray)
                {
                    if (new ConfigFile(szConfigPath).ReadConfig("$LANGUAGE_NAME").Trim() == str3)
                    {
                        str2 = szConfigPath;
                        break;
                    }
                }
                if (str2 != "")
                {
                    szLanguagePath = szFolder;
                    szLanguageFile = str2;
                }
                else
                {
                    int num2 = (int)MessageBox.Show("Can not load default language (English), use built-in language.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            if (szLanguagePath != "" && szLanguageFile != "")
            {
                GlobalMessages.LoadMessages(szLanguageFile);
            }

            if (!RegHelper.CheckConfigRegister())
            {
                int num3 = (int)MessageBox.Show(GlobalMessages.DRIVER_NOT_CONFIG, GlobalMessages.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                frmMain.SetLanguage(szLanguagePath, szLanguageFile);
                Application.Run(new frmMain(szArgs));
            }
        }
コード例 #5
0
        public static bool CheckConfigRegister()
        {
            int nBufferSize = 260;

            char[] destination1 = new char[nBufferSize * 2];
            char[] destination2 = new char[nBufferSize * 2];
            IntPtr num1         = Marshal.AllocHGlobal(nBufferSize * 2);
            int    num2         = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigPath", num1, nBufferSize);

            Marshal.Copy(num1, destination1, 0, nBufferSize * 2);
            int num3 = RegHelper.QueryRegistryStringValue("SOFTWARE\\ViPER4Windows", "ConfigFile", num1, nBufferSize);

            Marshal.Copy(num1, destination2, 0, nBufferSize * 2);
            Marshal.FreeHGlobal(num1);
            if (num2 == 0 || num3 == 0)
            {
                return(false);
            }

            string str1 = new string(destination1);
            string str2 = new string(destination2);

            if (string.IsNullOrEmpty(str1) || string.IsNullOrEmpty(str2))
            {
                return(false);
            }

            char[] charArray1 = str1.ToCharArray();
            int    length1    = -1;

            for (int index = 0; index < charArray1.Length; ++index)
            {
                if (charArray1[index] == char.MinValue)
                {
                    length1 = index;
                    break;
                }
            }
            if (length1 == -1)
            {
                return(false);
            }

            char[] chArray1 = new char[length1];
            Array.Copy(charArray1, chArray1, length1);
            string str3 = new string(chArray1);

            char[] charArray2 = str2.ToCharArray();
            int    length2    = -1;

            for (int index = 0; index < charArray2.Length; ++index)
            {
                if (charArray2[index] == char.MinValue)
                {
                    length2 = index;
                    break;
                }
            }
            if (length2 == -1)
            {
                return(false);
            }

            char[] chArray2 = new char[length2];
            Array.Copy(charArray2, chArray2, length2);
            string str4 = new string(chArray2);

            return(!string.IsNullOrEmpty(str3) && !string.IsNullOrEmpty(str4));
        }
コード例 #6
0
        public static bool WriteDWORD(string szKeyName, uint uiValue)
        {
            uint uiValue1 = uiValue;

            return(RegHelper.WriteRegistryDWORDValue("SOFTWARE\\ViPER4Windows", szKeyName, uiValue1) != 0);
        }
コード例 #7
0
 public static string GetConfig()
 {
     return(RegHelper.GetConfigPath() + "\\" + RegHelper.GetConfigFile());
 }