COM interface: IFileOperation - Example?

Windows specific forum
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

COM interface: IFileOperation - Example?

Post by highend »

I want to move a folder from one volume to another volume into an overlong path (on Windows).

Code: Select all

MoveFileEx_
and

Code: Select all

SHFileOperation_
can't do this unfortunately.

MoveFileEx_ can move files cross-volume (even into overlong paths) but fails to do this with folders.
SHFileOperation_ can move even folders cross-volume but doesn't support overlong paths at all, not even with the necessary prefix.

COM interfaces are a totally black box for me...

Does anybody have time to show an example of how to implement a function:

Code: Select all

MoveFolder(srcFolder.s, dstFolder.s) 
Which can move e.g.:

Code: Select all

\\?\D:\Temp\abc
into
\\?\C:\Temp\Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure proident consequat nisi\abc
?

The

Code: Select all

C:\Temp\Lorem... nisi\
folder does already exist

Thanks in advance!
Last edited by highend on Tue Jul 15, 2025 1:06 pm, edited 1 time in total.
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: COM interface: IFileOperation - Example?

Post by Thorium »

Here are some interessting information: https://learn.microsoft.com/en-us/windo ... limitation

It says in Windows 10 most API functions are updated to work with long path but you have to set longPathAware in the manifest of your application.
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: COM interface: IFileOperation - Example?

Post by highend »

@Thorium
Thanks for the hint but this won't be an option for me (even if it would work)

Why?
Adding the necessary manifest to my .exe isn't the problem but setting the registry value for
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled
is something that can't be done.

The computer on which this .exe will run is administered via MS InTune and that registry setting / GPO isn't active on such a PC and can't be set from a normal user account.
Post Reply