コード例 #1
0
        private static void checkWYZFileAssociation()
        {
            if (Properties.Settings.Default.CheckFileAssociation)
            {
                FileAssociationInfo fai = new FileAssociationInfo(".wyz");

                bool refreshAssociation = !fai.Exists;
                if (!refreshAssociation)
                {
                    ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
                    refreshAssociation = (!pai.Exists ||
                                          pai.Verbs.Length == 0 ||
                                          !pai.Verbs[0].Command.ToLower().Contains(Application.ExecutablePath.ToLower()));
                }

                if (refreshAssociation)
                {
                    DlgFileAssociationCheck dlgFileAssocCheck = new DlgFileAssociationCheck();
                    if (dlgFileAssocCheck.ShowDialog() == DialogResult.Yes)
                    {
                        Process newProcess = new Process();
                        newProcess.StartInfo.FileName  = Application.ExecutablePath;
                        newProcess.StartInfo.Verb      = "runas";
                        newProcess.StartInfo.Arguments = CREATE_ASSOC_PARAM;
                        newProcess.Start();
                        newProcess.WaitForExit();
                    }
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: AugustoRuiz/WYZTracker
        private static void checkWYZFileAssociation()
        {
            if (Properties.Settings.Default.CheckFileAssociation)
            {
                FileAssociationInfo fai = new FileAssociationInfo(".wyz");

                bool refreshAssociation = !fai.Exists;
                if (!refreshAssociation)
                {
                    ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
                    refreshAssociation = (!pai.Exists ||
                        pai.Verbs.Length == 0 ||
                        !pai.Verbs[0].Command.ToLower().Contains(Application.ExecutablePath.ToLower()));
                }

                if (refreshAssociation)
                {
                    DlgFileAssociationCheck dlgFileAssocCheck = new DlgFileAssociationCheck();
                    if (dlgFileAssocCheck.ShowDialog() == DialogResult.Yes)
                    {
                        Process newProcess = new Process();
                        newProcess.StartInfo.FileName = Application.ExecutablePath;
                        newProcess.StartInfo.Verb = "runas";
                        newProcess.StartInfo.Arguments = CREATE_ASSOC_PARAM;
                        newProcess.Start();
                        newProcess.WaitForExit();
                    }
                }
            }
        }