当应用程序在管理特权中运行时,如何将文件拖放到我的表单中 [英] How can I drop file to my form when application is running in administrative privilages

查看:74
本文介绍了当应用程序在管理特权中运行时,如何将文件拖放到我的表单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#.net上有一个简单的应用程序,我可以从资源管理器中删除任何文件并显示文件链接。

使用此代码

I have a simple application in C#.net on which i may drop any file from explorer and it shows the file link.
using this code

private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
            if (a != null)
            {
                string s = a.GetValue(0).ToString();
                MessageBox.Show(s);


            }

        }





但是当我运行这个申请作为管理员。应用程序停止删除文件。并且鼠标箭头更改看起来像是不允许文件丢弃而不是表单上的文件复制箭头。



我该如何解决?我想在任何条件下启用drop。应用程序是以管理员还是普通用户身份运行。



任何人如果有帮助的话。或者任何解决方法都将受到高度赞赏。

谢谢。



But when I run this application as an administrator. The application stops dropping the files. And and mouse arrow changes looks like file drop is not allowed appears instead of file copy arrow on the form.

How may I solve it? I want to enable drop in any condition. either app is running in as administrator or normal user.

Any one if help on this.? Or any workaround will be highly appreciated.
Thank you.

推荐答案

你无法解决它。允许非特权和特权进程之间的交互是一种巨大的安全违规行为。通过允许这一点,您实际上给予非管理员进程(桌面)比用户登录所允许的更多权限。
You can't solve it. It's a HUGE security violation to allow interaction between non-priviledged and priviledged processes. By allowing this, you're essentially giving the non-admin process (the Desktop) more priviledges than allowed by the users login.


这篇关于当应用程序在管理特权中运行时,如何将文件拖放到我的表单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆