与应用程序文件类型关联

与应用程序文件类型关联

本文介绍了与应用程序文件类型关联(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个问题相关的:

1)有可能使我的程序变更的文件类型关联,但只有当运行?你看到什么不对这种行为?

1) Is possible to make my program change filetype association but only when is running? Do you see anything wrong with this behavior?

2)我看到的另一种选择是让用户决定开放与我的应用程序或恢复默认协会...类似:捕获所有.lala文件或恢复.lala协会。我怎样才能做到这一点?你觉得这是最好的办法?

2) The other option that I'm seeing is to let users decide to open with my application or restore default association ... something like: "capture all .lala files" or "restore .lala association". How can I do this? What do you think that is the best approach?

推荐答案

对于文件关联,我写了一个答案早些时候,至少covers 如何。

Regarding file associations, I've wrote an answer earlier that at least covers the "How".

这应该也指向您正确的方向如何处理备份和恢复。通过C#直接注册表访问,就没有必要使用reg文件,所以你可以自由备份previous值,但是你喜欢你的应用程序,也从那里恢复。

This should also point you to the right direction how to handle backup and restore. With direct registry access through c#, there will be no need to use .reg files, so you are free to back up the previous value however you like in your app, and also restore it from there.

这里的关键问题是:的你随意更改文件关联?至少要求用户前期显然是必要的(你也表示)。

The key question here is: Should you change file associations randomly? At least asking the user up-front would obviously be necessary (as you also indicated).

此外,Vista用户启用了UAC,或其他Windows版本的非特权用户可能没有改变全球文件关联所需的权限。你的程序的(联合国)的安装过程可能会这样将能取得成功的唯一地方。

Furthermore, Vista users with UAC enabled, or non-privileged users of other Windows versions may not have the required permission to change global file associations. The (un)installation procedure of your program may be the only place where this can succeed.

修改

作为Franci佩诺夫在他的回答指出,有的的方式在改变本地文件关联,在每个用户的基础上,即使对于非管理员(这就是为什么我讲的全球关联的previous段)。他还提到提及为何去那里是不是太明智。

As Franci Penov indicated in his answer, there is a way to change local file associations on a per-user basis, even for non-admins (that's why I spoke of "global associations" in the previous paragraph). He also mentioned mentioned why going there is not overly advisable.

这篇关于与应用程序文件类型关联(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 07:56