This useful answer shows how one can copy the given files to the clipboard. Is it possible in a similar way to copy files from a zip archive, as Explorer does? One can unzip the archive to a temporary folder and copy from there, but then there is a problem of subsequent deletion of the files, since it is not known when they can be deleted (the program may already be closed at this time).
Asked
Active
Viewed 209 times
0
-
3Zip file contents aren't real files. To put them on the clipboard directly (rather than via a temporary file) you need to actually be able to extract the contents yourself, and provide an [IDataObject](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-idataobject) that presents the [CFSTR_FILECONTENTS](https://learn.microsoft.com/en-us/windows/win32/shell/clipboard#cfstr_filecontents) data format that lets other apps read the data stream. – Jonathan Potter Nov 09 '21 at 09:07
-
@Jonathan Potter This solves the problem of temporary files, but not the problem of closing the program. When the process ends, the `IDataObject` will be destroyed, right? – AVK Nov 09 '21 at 09:22
-
Theoretically an object on the clipboard can outlive the program that put it there. – Jonathan Potter Nov 09 '21 at 11:47
-
Yes, but if the object refers to a zip that doesn't exist anymore then the object should be removed from the clipboard. – Remy Lebeau Nov 09 '21 at 17:22