Exemple #1
0
        private void UnRegExtfile()
        {
            bool rel = FileTypeRegister.UnRegister(_myExtName);

            if (!rel && IsWindowsVistaOrNewer)
            {
                MessageBox.Show("您是在windows7 下运行的此程序,如果执行完扩展名关联但没有成功,请您以“管理员权限方式再打开此程序再关联一次”!");
            }
        }
Exemple #2
0
        private void regExtFile()
        {
            Assembly   asm          = Assembly.GetExecutingAssembly();
            string     resourceName = "MEditor.logo.ico";
            Stream     stream       = asm.GetManifestResourceStream(resourceName);
            string     icofile      = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\markdown.ico";
            FileStream fs           = new FileStream(icofile, FileMode.Create, FileAccess.Write);

            byte[] bs = new byte[stream.Length];
            stream.Read(bs, 0, (int)stream.Length);
            fs.Write(bs, 0, bs.Length);
            fs.Flush();
            fs.Close();
            fs.Dispose();

            //注册关联的文件扩展名
            FileTypeRegInfo fr = new FileTypeRegInfo();

            fr.Description = "markdown文档格式";
            fr.ExePath     = Application.ExecutablePath;
            fr.ExtendName  = _myExtName;
            fr.IcoPath     = icofile;

            bool rel = true;

            if (FileTypeRegister.CheckIfRegistered(fr.ExtendName))
            {
                rel = FileTypeRegister.UpdateRegInfo(fr);
            }
            else
            {
                rel = FileTypeRegister.Register(fr);
            }

            if (!rel && IsWindowsVistaOrNewer)
            {
                MessageBox.Show("您是在windows7 下运行的此程序,如果执行完扩展名关联但没有成功,请您以“管理员权限方式再打开此程序再关联一次”!");
            }
        }