简体   繁体   中英

Drag and Drop External File onto VB6 ListView Control

I am trying to drop an external file (from windows file explorer) onto a ListView control. I have done this before but can't seem to get the events to fire.

My steps are as follows:

  • Create a ListView Control
  • Set the View property to 3 - lvwReport
  • Set the OLEDropMode property to 1 -ccOLEDropManual

I thought that was all I had to do but my ListView1_OLEDragDrop event does not fire.

I populated the ListView with a couple of items just in case.

I tried setting the Effect = vbDropEffectCopy in the ListView1_OLEDragOver and the ListView1_OLEGiveFeedback but this seems to have no effect either (this doesn't even change the cursor)

Note: I can get the StartDrag event to fire when dragging out of the control

Can someone confirm that this still works on windows 7?

It appears to be UIPI (User Interface Privilege Isolation) , a new security feature that wont allow lower privilege applications to interface with higher privliege applications. It can be bypassed, mainly to allow for UI automation applications. To bypass three things must be done:

1. Create a pfx file and import it as a trusted root certificate authority.

To create a pfx file download Openssl and from a command prompt run:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

Then,

openssl pkcs12 -export -out mycert.pfx -in mycert.pem -name "My Certificate"

Then import the certificate: 选择证书存储

2. Sign your program with your certifcate with signtool, which comes with Visual Studio, by entering the following in a command prompt:

signtool sign /t http://timestamp.digicert.com /f "c:\path\to\mycert.pfx" /p pfxpassword "c:\path\to\file.exe"

3. Include a trustInfo section with the UIaccess definition set to true in a manifest file for your exe. I did this using Make My Manifest :

MMM

Now, the app should be able to bypass UIPI, but only when run from a secure location, such as "C:\\Program Files\\", "C:\\Windows\\", or a subdirectory of either.

Alternatively, you could just disable UAC.

It appears that dragging and dropping onto the ListView does not work when Running as Administrator.

  • When I try this in the IDE (which is set to run As Admin) it doesn't work.
  • If I use my compiled exe it works, but if I run my compiled exe as Admin (right click Run As Admin ) it doesn't work.

I don't know why is doesn't work however

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