Menu

#2625 Source object not removed from archive during move drag-and-drop

open
None
5
2026-02-24
2026-02-17
No

During drag-and-drop from app, DoDragDrop is called with dwOKEffects=3 (Copy|Move):

#   Time of Day Thread  Module  API Return Value    Error   Duration
1   10:59:07.481 AM 1   7zFM.exe    DoDragDrop ( 0x00000000002bac90, 0x0000000000475aa0, 3, 0x00000000001aedc8 )    DRAGDROP_S_DROP     0.6383695
#   Type    Name    Pre-Call Value  Post-Call Value
1   LPDATAOBJECT    pDataObj    0x00000000002bac90  0x00000000002bac90
2   LPDROPSOURCE    pDropSource 0x0000000000475aa0  0x0000000000475aa0
3   DWORD   dwOKEffects 3   3
4   LPDWORD pdwEffect   0x00000000001aedc8 = 0  0x00000000001aedc8 = 2
    HRESULT Return      DRAGDROP_S_DROP

but if pdwEffect value is set to Move (2), 7-Zip doesn't remove the source object from the archive.
7-Zip 26.00 x64 on Windows 7 SP1.

Discussion

  • Igor Pavlov

    Igor Pavlov - 2026-02-17

    Deleting from an archive from "Move" is a dangerous operation where data loss is possible. And it can be expensive operation because recompression can be required in some cases.
    So we try to use Copy instead of Move.

     
  • Nikita Leontiev

    Nikita Leontiev - 2026-02-17

    Then you need to set allowed operations (dwOKEffects) to 1 (Copy).

     
  • Igor Pavlov

    Igor Pavlov - 2026-02-17

    I don't remember details.
    Each selected decision in that code had some reasons.
    You can look source code, maybe there are some comments there.

     
  • Igor Pavlov

    Igor Pavlov - 2026-02-17

    some long comments from source code.
    I hope these comments are related to that issue?

      CTime - file creation timestamp.
      There are two operations in Windows with Drag and Drop:
        COPY_OPERATION : icon with    Plus sign : CTime will be set as current_time.
        MOVE_OPERATION : icon without Plus sign : CTime will be preserved.
    
      Note: if we call DoDragDrop() with (effectsOK = DROPEFFECT_MOVE), then
        it will use MOVE_OPERATION and CTime will be preserved.
        But MoveFile() function doesn't preserve CTime, if different volumes are used.
        Why it's so?
        Does DoDragDrop() use some another function (not MoveFile())?
    
      if (effectsOK == DROPEFFECT_COPY) it works as COPY_OPERATION
    
      if (effectsOK == DROPEFFECT_MOVE) drag works as MOVE_OPERATION
    
      if (effectsOK == (DROPEFFECT_COPY | DROPEFFECT_MOVE))
      {
        if we drag file to same volume, then Windows suggests:
           CTRL      - COPY_OPERATION
           [default] - MOVE_OPERATION
    
        if we drag file to another volume, then Windows suggests
           [default] - COPY_OPERATION
           SHIFT     - MOVE_OPERATION
      }
    
      We want to use MOVE_OPERATION for extracting from archive (open in 7-Zip) to Explorer:
      It has the following advantages:
        1) it uses fast MOVE_OPERATION instead of slow COPY_OPERATION and DELETE, if same volume.
        2) it preserves CTime
    
      Some another programs support only COPY_OPERATION.
      So we can use (DROPEFFECT_COPY | DROPEFFECT_MOVE)
    
      Also another program can return from DoDragDrop() before
      files using. But we delete temp folder after DoDragDrop(),
      and another program can't open input files in that case.
    
      We create objects:
        IDropSource *dropSource
        IDataObject *dataObject
      if DropTarget is 7-Zip window, then 7-Zip's
        IDropTarget::DragOver() sets DestDirPrefix_FromTarget in IDataObject.
      and
        IDropSource::QueryContinueDrag() sets DoNotProcessInTarget, if DestDirPrefix_FromTarget is not empty.
      So we can detect destination path after DoDragDrop().
      Now we don't know any good way to detect destination path for D&D to Explorer.
    
     

    Last edit: Igor Pavlov 2026-02-17
  • Nikita Leontiev

    Nikita Leontiev - 2026-02-18

    I see, you are using the move effect to force the target app to move file object from temp to the target location if they are on the same logical drive.
    Why not to use FileGroupDescriptor format that is designed for virtual objects?

     
  • Igor Pavlov

    Igor Pavlov - 2026-02-18

    I don't remember why it's so.
    Does FileGroupDescriptor format support alternate data streams and creation timestamps in files?
    But it's another thing.
    Your original question was about dwOKEffects.

     
  • Nikita Leontiev

    Nikita Leontiev - 2026-02-24

    FileGroupDescriptor format supports creation, last access and last write timestamps. The data is transferred via FileContents format, which supports several media types: global memory, IStream, IStorage, e.t.c.

     

Log in to post a comment.

MongoDB Logo MongoDB