维斯塔& C# - 拖放 跌落问题(与海拔无关)

发布于 2024-07-14 05:02:50 字数 265 浏览 5 评论 0 原文

有问题的应用程序是.Net 2.0 Framework WinForms。 它应该适用于大量用户群(从 CD 安装)。 使用 InnoSetup 完成安装。

在两台机器上,应用程序不接受拖放 掉落(D&D 的应用程序和源具有相同的海拔高度)。

通过添加读取和 应用程序快捷方式的 INTERACTIVE SID 的读取和执行权限,这个问题似乎已经解决。

问题:添加这些权限和D&D有何关系以及如何在安装过程中检查/设置这些权限?

Application in question is .Net 2.0 Framework WinForms. It is supposed to work on large user base (installation from CD). Installation done using InnoSetup.

On two machines, application does not accept Drag & Drop (both application and source of D&D have same elevation level).

By adding Read & Read&Execute rights to INTERACTIVE SID for application shortcut, this problem appears to be solved.

Question: how adding those rights and D&D are related and how to check / set those rights in Installation process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦中的蝴蝶 2024-07-21 05:02:50

您在这里有两个问题:

  1. 添加这些权利与 D&D 有何关联以及……

这一点我完全不确定。 我们在 WinForm 应用程序中使用 D&D 与 shell 和 Outlook 之间进行交互,在 Vista 中没有任何问题。 我什至不确定您建议的 ACL 更改是否一定能解决您遇到的任何问题。

  • 如何在安装过程中检查/设置这些权限?
  • 执行此操作的简单方法是 创建一个 .Net安装类并添加以下代码:

        public static void ReplacePermissions(string filepath, WellKnownSidType sidType, FileSystemRights allow)
        {
            FileSecurity sec = File.GetAccessControl(filepath);
            SecurityIdentifier sid = new SecurityIdentifier(sidType, null);
            sec.PurgeAccessRules(sid); //remove existing
            sec.AddAccessRule(new FileSystemAccessRule(sid, allow, AccessControlType.Allow));
            File.SetAccessControl(filepath, sec);
        }
    

    You have two questions here:

    1. how adding those rights and D&D are related and ...

    This I'm totally unsure about. We use D&D in our WinForm app to/from the shell and Outlook without any issues in Vista. I'm not even certain the ACL change you suggest will be certain to fix whatever issue your having.

    1. how to check / set those rights in Installation process?

    The easy way to do this is to create a .Net install class and add the following code:

        public static void ReplacePermissions(string filepath, WellKnownSidType sidType, FileSystemRights allow)
        {
            FileSecurity sec = File.GetAccessControl(filepath);
            SecurityIdentifier sid = new SecurityIdentifier(sidType, null);
            sec.PurgeAccessRules(sid); //remove existing
            sec.AddAccessRule(new FileSystemAccessRule(sid, allow, AccessControlType.Allow));
            File.SetAccessControl(filepath, sec);
        }
    
    毁虫ゝ 2024-07-21 05:02:50

    只是一个猜测,但是 [STAThread] 属性是否存在于应用程序的 Main() 方法中? 没有它,拖放根本不起作用。 (尽管这无法解释随着 INTERACTIVE SID 上的权利变化而发生的行为变化)。

    Just a shot in the dark, but is the [STAThread] attribute present on your application's Main() method? Without it, drag and drop won't work at all. (Although this fails to explain the change in behavior with the change of rights on INTERACTIVE SID).

    飘逸的'云 2024-07-21 05:02:50

    您应该在 Visual Studio 环境之外直接运行项目的 exe 文件。 我正在 Windows Vista 平台上工作。

    You should run the exe file for the project directly and outside of the environment of Visual Studio. I'm working on a Windows Vista platform.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文