Ejemplo n.º 1
0
        public static extern int SendMessage(IntPtr hwnd, int msg, int wp, int lp);//用鼠标拖动窗体,移动窗体

        public RegDlgOld()
        {
            iniLanguage = ini.read_ini("language");
            if (string.IsNullOrEmpty(iniLanguage))
            {
                iniLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name;
            }
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(iniLanguage);
            InitializeComponent();
        }
Ejemplo n.º 2
0
        public RegDlg01()
        {
            //引入多语言
            iniLanguage = ini.read_ini("language");
            if (string.IsNullOrEmpty(iniLanguage))
            {
                iniLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name;
            }

            InitializeComponent();
        }
Ejemplo n.º 3
0
        public PassWordDlg01(string file_name)
        {
            this.file_name = file_name;
            //引入多语言
            iniLanguage = ini.read_ini("language");
            if (string.IsNullOrEmpty(iniLanguage))
            {
                iniLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name;
            }

            InitializeComponent();

            this.Size = new Size(420, 300);//窗体界面固定大小(防止程序员不小心改变了大小,因为是多语言界面,窗体大小是固定的)

            switch (Program.iniLanguage.ToLower())
            {
            case "zh-cn":
                spath01 = Application.StartupPath + "\\zh-CN\\PassWordDlg01\\";
                break;

            case "en":
                spath01 = Application.StartupPath + "\\en\\PassWordDlg01\\";
                break;

            case "ja":
                spath01 = Application.StartupPath + "\\Ja\\PassWordDlg01\\";
                break;

            case "zh-tw":
                spath01 = Application.StartupPath + "\\zh-TW\\PassWordDlg01\\";
                break;

            default:
                spath01 = Application.StartupPath + "\\zh-CN\\PassWordDlg01\\";
                break;
            }
        }
Ejemplo n.º 4
0
        static void Main()
        {
            #region 当前用户是管理员的时候,直接启动应用程序,如果不是管理员,则使用启动对象启动程序,以确保使用管理员身份运行
            //获得当前登录的Windows用户标示
            System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
            //创建Windows用户主题
            Application.EnableVisualStyles();

            System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
            //判断当前登录用户是否为管理员
            if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
            {
                //如果是管理员,则直接运行
                // Application.EnableVisualStyles();
                // Application.Run(new Form1());
            }
            else
            {
                //创建启动对象
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                //设置运行文件
                startInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
                //设置启动参数
                //startInfo.Arguments = String.Join(" ", Args); //Args为“static void Main(string[] Args) ”使用的参数
                //设置启动动作,确保以管理员身份运行
                startInfo.Verb = "runas";
                //如果不是管理员,则启动UAC
                System.Diagnostics.Process.Start(startInfo);
                //退出
                //System.Windows.Forms.Application.Exit();
            }
            #endregion

            appProgName = Encrypt.Refresh();
            //MessageBox.Show("程序运行到这里了 11111");
            CheckOSVersion(); //检查操作系统的版本
            //MessageBox.Show("程序运行到这里了 22222");
            try
            {
                SkipUAC(); //解决UAC的控制问题,单独编一个程序,DotNetFrameWork是2.0或4.5都过的,但是放在这里就不行,2015-11-03查出原因,是因为app.manifest里面的这条语句在影响<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
            }
            catch
            {
                //Win7 32位有时会卡在这里,所以这句话如果出错就略过
            }
            Application.EnableVisualStyles();                     //样式设置
            Application.SetCompatibleTextRenderingDefault(false); //样式设置

            iniLanguage = ini.read_ini("language").ToLower();
            if (string.IsNullOrEmpty(iniLanguage))
            {
                //iniLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name.ToLower();
                //获取操作系统语言 using System.Runtime.InteropServices;
                string sLanguage = string.Empty;
                sLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.Name.ToLower();
                if (string.IsNullOrEmpty(sLanguage) == true || string.Equals(sLanguage, "") == true)
                {
                    sLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name.ToLower();
                }
                if (sLanguage.Substring(0, 2).ToLower() == "en")
                {
                    sLanguage = "en";
                }
                if (sLanguage.Substring(0, 2).ToLower() == "ja" || sLanguage.Substring(2).ToLower() == "jp")
                {
                    sLanguage = "ja";
                }
                if (sLanguage.Substring(0, 2).ToLower() == "zh-TW".ToLower() || sLanguage.Substring(2).ToLower() == "zh-HK".ToLower())
                {
                    sLanguage = "zh-tw";
                }
                if (string.IsNullOrEmpty(sLanguage) == true || string.Equals(sLanguage, "") == true)
                {
                    sLanguage = "zh-cn";
                }
                iniLanguage = sLanguage;
            }
            if (iniLanguage.Substring(0, 2).ToLower() == "ja" || iniLanguage.Substring(2).ToLower() == "jp")
            {
                iniLanguage = "ja";
            }
            if (iniLanguage.Substring(0, 2).ToLower() == "zh-TW".ToLower() || iniLanguage.Substring(2).ToLower() == "zh-HK".ToLower())
            {
                iniLanguage = "zh-tw";
            }

            try
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(iniLanguage);
            }
            catch
            {
                //如果ini里面的language定义错误,则默认语言版本为中文,此时尽量不默认为英文,因为目前英文版是免费的,免得有的用户不小心发现这个秘密"英文版免费"
                iniLanguage = "zh-cn";
            }
            License();

            RunForm();                               //启动窗体
        }
Ejemplo n.º 5
0
        private void dl_config()
        {
            AddText     method = new AddText(this.add_text);
            AddListItem item   = new AddListItem(this.add_list_item);

            base.Invoke(method, new object[] { "检测是否有新版本..." });
            base.Invoke(method, new object[] { "读取远程配置文件..." });
            ini_config _config = new ini_config("config.ini");

            try
            {
                bool   flag   = false;
                Thread thread = new Thread(new ThreadStart(this.GetAddress))
                {
                    IsBackground = true
                };
                thread.Start();
                thread.Join();
                if (!string.IsNullOrEmpty(this.text))
                {
                    if (this.text.IndexOf("#END#") == -1)
                    {
                        throw new Exception();
                    }
                    string[] strArray = this.text.Split(Environment.NewLine.ToCharArray());
                    string   str      = string.Empty;
                    string   str2     = _config.read_ini("VeryPdf", "App");
                    string   str3     = string.Empty;
                    string   str4     = "";
                    for (int i = 0; i < (strArray.Length - 1); i++)
                    {
                        if (strArray[i] != string.Empty)
                        {
                            if (strArray[i].Contains("#END#"))
                            {
                                break;
                            }
                            if (strArray[i].Contains("version"))
                            {
                                str = strArray[i].Split(new char[] { ',' })[1];
                            }
                            else if (strArray[i].Contains("veryPdf"))
                            {
                                str3 = strArray[i].Split(new char[] { ',' })[1];
                            }
                            else
                            {
                                string[] strArray2 = strArray[i].Split(new char[] { ',' });
                                if (!(PDF_Convert.Version.dic_ver.TryGetValue(strArray2[0], out str4) && (System.Convert.ToInt32(PDF_Convert.Version.dic_ver[strArray2[0]].Replace(".", "")) >= System.Convert.ToInt32(strArray2[1].Replace(".", "")))))
                                {
                                    this.dl_lst.Add(new detail_list(strArray2[2], System.Convert.ToInt32(strArray2[3])));
                                    base.Invoke(item);
                                    flag = true;
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(str3))
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(str2) || (System.Convert.ToDouble(str2) < System.Convert.ToDouble(str3)))
                            {
                                this.dl_lst.Add(new detail_list("VeryPdf.rar", 0x4f832a));
                                base.Invoke(item);
                                flag = true;
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (flag)
                    {
                        base.Invoke(new _Show(this.show_this_window));
                        base.Invoke(method, new object[] { "开始下载新文件..." });
                        Thread thread2 = new Thread(new ThreadStart(this.dl_file))
                        {
                            IsBackground = true
                        };
                        thread2.Start();
                        thread2.Join();
                        ProcessStartInfo startInfo = new ProcessStartInfo(Application.StartupPath + @"\PDF Update.exe")
                        {
                            Arguments = "Madoka " + Process.GetCurrentProcess().Id.ToString()
                        };
                        foreach (detail_list _list in this.dl_lst)
                        {
                            startInfo.Arguments = startInfo.Arguments + string.Format(" \"{0}\"", _list.file_name);
                        }
                        Process.Start(startInfo);
                        base.Invoke(method, new object[] { "下载新文件成功,程序即将退出以便进行更新" });
                        Thread.Sleep(0x3e8);
                        _config.write_ini("Version", str, "App");
                        _config.write_ini("VeryPdf", str3, "App");
                    }
                    base.Invoke(new _Exit(this.Close));
                }
            }
            catch
            {
                base.Invoke(new _Exit(this.Close));
            }
        }
Ejemplo n.º 6
0
        public string newVersion; //最新版本

        public frmAutoUpdate01()
        {
            //自动更新右上角不允许有“关闭”,只能是确定或者取消,这样如果php网站定义了新版本必须更新时,用户无论如何都得去更新了(就要这种效果)
            //此界面的调试方法:
            //    1、打开MainInfo01.cs里面的注释“Thread trd = new Thread(statisticsPost)”,同时需要把MainInfo01.cs里面的“Program.httpVersion = "6.3"”版本变低,这样就会自动到PHP网站查找更新了(这种方法比较麻烦)
            //    2、需要在MainInfo01.cs窗体里面增加一个按钮,然后用下面的程序调试它:

            /*
             *       private void test_frmAutoUpdate01(object sender, EventArgs e)
             *      {
             *          //测试额外frmAutoUpdate01专用,需增加一个测试按钮
             *          //private void button1_Click(object sender, EventArgs e)
             *          //{
             *          //    test_frmAutoUpdate01(sender, e);
             *          //}
             *          frmAutoUpdate01 frm = new frmAutoUpdate01();
             *          //frm.TopMost = true; //异步的窗口ShowDialog是不会阻塞主窗口的,你只能在主窗口线程创建。使用这个属性就可以把窗体一直放在所有窗体的最前面,这样也可以起到这种效果
             *          frm.StartPosition = FormStartPosition.CenterParent;//放置于父窗体中间位置
             *          frm.Location = this.PointToScreen(new Point(400, this.lstFile.Location.Y + 30));
             *          if (MessageBox.Show("调试1个按钮还是2个按钮: Yes-1,No-2", "测试frmAutoUpdate窗体是否显示正常", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
             *          {
             *              frm.cancelShow = true; //是否显示“跳过”按钮,在调试时要注意把它修改为false进行调试
             *          }
             *          DialogResult dr = frm.ShowDialog(); //此处代码的目的是
             *      }
             *
             *      private void button1_Click(object sender, EventArgs e)
             *      {
             *          test_frmAutoUpdate01(sender, e);
             *      }
             */

            //引入多语言
            iniLanguage = ini.read_ini("language");
            if (string.IsNullOrEmpty(iniLanguage))
            {
                iniLanguage = System.Globalization.CultureInfo.InstalledUICulture.Name;
            }

            InitializeComponent();

            this.Size = new Size(340, 199);//窗体界面固定大小(防止程序员不小心改变了大小,因为是多语言界面,窗体大小是固定的)

            switch (Program.iniLanguage.ToLower())
            {
            case "zh-cn":
                spath01   = Application.StartupPath + "\\zh-CN\\frmAutoUpdate01\\";
                this.Size = new System.Drawing.Size(340, 199);
                break;

            case "en":
                spath01 = Application.StartupPath + "\\en\\frmAutoUpdate01\\";
                break;

            case "ja":
                spath01   = Application.StartupPath + "\\Ja\\frmAutoUpdate01\\";
                this.Size = new System.Drawing.Size(420, 199);
                this.pbConfirm.Location = new Point(87, 147);
                this.pbOver.Location    = new Point(234, 147);
                break;

            case "zh-tw":
                spath01 = Application.StartupPath + "\\zh-TW\\frmAutoUpdate01\\";
                break;

            default:
                spath01 = Application.StartupPath + "\\zh-CN\\frmAutoUpdate01\\";
                break;
            }
        }