Using IKnownFolderManager
and IKnownFolder
I managed to get the path to C:\Program Files and its corresponding IShellItem
. After that I managed to create a directory in that location using IFileOperation
. Now, I want to create a file in the new directory. Since IFileOperation
needs IShellItem
, how do I get the corresponding IShellItem
of the new directory?
PS: I'm new to COM and Win32 API.
CodePudding user response:
When using IFileOperation::NewItem()
, you can use an IFileOperationProgressSink
object, its PostNewItem()
event will give you the IShellItem
of the new item you create. You can either pass the sink object to NewItem()
directly, or pass it to IFileOperation::Advise()
before calling IFileOperation::PerformOperations()
.
Alternatively, you can use SHCreateItemFromRelativeName()
instead, after PerformOperations()
is successful.