简体   繁体   中英

Drag and drop event can not be fired when running visual studio in Administrator account

I use Visual Studio 2008, .net framework 3.5

I have an webservice application (a winform client which is using webservice), and I have to run it in Administrator account

I need to drag and drop files from windows explorer to a form of this application.

Here is my code:

this.AllowDrop = true;

private void Form1_DragEnter(object sender, DragEventArgs e)
    {

        if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
            e.Effect = DragDropEffects.All;
    }

private void Form1_DragDrop(object sender, DragEventArgs e)
    {
        string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
        foreach (string s in fileList)
        {
            MessageBox.Show(s);
        }

    }

It works when I run in normal account, but in Administrator It doesn't. How to solve it?

This question was also raised here: Drag and drop not working in C# The answer is that "Starting from Windows Vista because of User Interface Privilege Isolation you cannot drag and drop from an application running at lower integrity level to an application which runs on a higher level."

See http://blogs.msdn.com/b/patricka/archive/2010/01/28/q-why-doesn-t-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi.aspx for details

PS The comment referencing duplication is also correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM