private void frmUpgradeBuilder_Load(object sender, EventArgs e) { #region 自动注册文件类型 if (!FileTypeRegister.FileTypeRegistered(".upb")) { FileTypeRegInfo fileTypeRegInfo = new FileTypeRegInfo(".upb"); fileTypeRegInfo.Description = "IRAP 自动更新工程文件"; fileTypeRegInfo.ExePath = Application.ExecutablePath.Replace('/', '\\'); fileTypeRegInfo.ExtendName = ".upb"; fileTypeRegInfo.IcoPath = Application.ExecutablePath.Replace('/', '\\'); FileTypeRegister.RegisterFileType(fileTypeRegInfo); } #endregion WindowState = FormWindowState.Maximized; #region 检查当前应用是否以管理员权限运行 WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); bool isRunasAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator); #endregion btnRegisterApp.Enabled = isRunasAdmin; if (!btnRegisterApp.Enabled) { btnRegisterApp.SuperTip = new SuperToolTip(); btnRegisterApp.SuperTip.Items.Add("当前功能需要程序具有管理员权限才能使用!"); } }
/// <summary> /// 绑定扩展名 /// </summary> private void BindingExtend() { if (!FileTypeRegister.FileTypeRegistered(SystemCommon.Extension)) { FileTypeRegInfo fileTypeRegInfo = new FileTypeRegInfo(SystemCommon.Extension); fileTypeRegInfo.Description = SystemCommon.SystemName + "缓存文件"; fileTypeRegInfo.ExePath = SystemCommon.ApplicationName; fileTypeRegInfo.ExtendName = SystemCommon.Extension; fileTypeRegInfo.IconPath = SystemCommon.ApplicationName; // 注册 //FileTypeRegister fileTypeRegister = new FileTypeRegister(); FileTypeRegister.RegisterFileType(fileTypeRegInfo); } }
public void CreatRegData() { if (!FileTypeRegister.FileTypeRegistered(filetype)) { Debug.LogFormat("文件类型 {0} 注册中!",filetype); FileTypeRegInfo fileTypeRegInfo = new FileTypeRegInfo(filetype) { Description = "测试自定义文件系统", ExePath = System.Environment.GetCommandLineArgs()[0], ExtendName = filetype, IconPath = Path.Combine(UnityEngine.Application.streamingAssetsPath, string.Format("{0}.ico", iconName)) }; // 注册 FileTypeRegister fileTypeRegister = new FileTypeRegister(); FileTypeRegister.RegisterFileType(fileTypeRegInfo); } else { Debug.LogFormat("文件类型 {0} 已经存在中!", filetype); } }
private void Start() { if (FileTypeRegister.FileTypeRegistered(filetype)) { Debug.Log("文件类型已经存在~-"+filetype); FileTypeRegInfo regInfo =FileTypeRegister.GetFileTypeRegInfo(filetype); if (!File.Exists(regInfo.ExePath)||regInfo.ExePath!=executePath) { DialogResult dialogResult= MessageBox.Show(string.Format("文件系统{0}丢失打开方式,是否修复?", filetype),"警告:文件系统异常",MessageBoxButtons.OKCancel); if (dialogResult==DialogResult.OK) { regInfo.ExePath = executePath; regInfo.IconPath = Path.Combine(UnityEngine.Application.streamingAssetsPath, string.Format("{0}.ico", iconName)); FileTypeRegister.UpdateFileTypeRegInfo(regInfo); } } } else { Debug.LogWarning("文件类型不存在~-" + filetype); MessageBox.Show("文件系统尚未创建!"); } }