Custom Explorer InfoTip using .NET 8 COM Hosting
See the question and my original answer on StackOverflowDocumentation common to Shell Extension Handlers stipulates this:
Most extension handlers must also implement either an IPersistFile or IShellExtInit interface in Windows XP or earlier. These were replaced by
IInitializeWithStream
,IInitializeWithItem
andIInitializeWithFile
in Windows Vista. The Shell uses these interfaces to initialize the handler.
They are used by the Shell to tell you what Shell Item in particular, information is requested for.
Note that if you want to support "virtual" Shell Items, that is Shell Items in namespace extensions not necessarily backed by physical files (like items on Internet drives or SmartPhones, etc.), you must use IInitializeWithStream
or IInitializeWithItem
.
If you only plan to support physical file you can only implement IInitializeWithFile
which you can declare like this:
[ComImport, Guid("b7d14566-0509-4cce-a71f-0a554233bd9b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInitializeWithFile
{
[PreserveSig]
int Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint grfMode);
}