Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SHFileOperation works but prints error messages

I'm using Shell API to copy a folder with files.

SHFILEOPSTRUCT sf = {0};
sf.wFunc = FO_COPY;
sf.hwnd = 0;
sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SILENT | FOF_NO_UI;
sf.pFrom = "C:\\Users\\Sergi0\\AppData\\Local\\Temp\\untar.temp\\000\0";
sf.pTo = "F:\\\0";

// both pFrom and pTo are double NULL terminated, I have rechecked it

int err = SHFileOperation(&sf);

Everything works fine, folder is copied to the drive F: The problem is that messages

internal\sdk\inc\wil\filesystem.h(820)\windows.storage.dll!7684045C: (caller: 7676413A) ReturnHr(2) tid(660) 80070057 Incorrect parameter.
...
internal\sdk\inc\wil\filesystem.h(820)\windows.storage.dll!7684045C: (caller: 7676413A) ReturnHr(101) tid(660) 80070057 Incorrect parameter.

are printed in Visual Studio debug console. There are 100 files inside folder 000 and 100 messages were printed.

Should I be worried about these? I'm using VS 2017 on Windows 10.

UPDATE I have tried with another device, I see the same errors in both VS2017 and VS2008. But, there are no such errors with generic flash drive. So it seems it has something to do with mass storage implementation on the devices I use. I didn't find file filesystem.h anywhere in SDK.

like image 792
Sergi0 Avatar asked Feb 05 '18 16:02

Sergi0


Video Answer


2 Answers

You don't need to worry about these messages. The copy engine is trying to get information about the destination directory (F:\) but it turns out that it's not a directory; it's a drive. The error is returned ("Silly copy engine, that's not a directory."), the copy engine says "Sorry," and everything proceeds normally.

Sorry for creating unnecessary alarm.

like image 58
Raymond Chen Avatar answered Oct 27 '22 06:10

Raymond Chen


Should I be worried about these?

If the files are being copied correctly, and SHFileOperation() is not reporting an error back to your code, then no, do not worry about it. The debug messages are internal to the API and the "incorrect parameter" errors are being handled internally by the API.

On the other hand, SHFILEOPSTRUCT does have an fAnyOperationsAborted field that will be set to TRUE if any of the individual files fails to copy. SHFileOperation() itself may be successful overall, but individual files may have failed, so your code should check for that condition.

like image 21
Remy Lebeau Avatar answered Oct 27 '22 07:10

Remy Lebeau