Getting an IStream on a File

By Eric

Getting a COM IStream instance on a normal file seems like something that should be trivial to do, but it always seems to take some hunting to remember how it is actually done.

There is a function in the shell API that will return an IStream on a file: SHCreateStreamOnFile. It is in version 5 or later of the shell, which is the version that shipped with Windows 2000, but comes along with IE 5 or later for older operating systems.

I've also heard people suggest that there is a similar function in the Extended MAPI library, but using the shell seems generally more palatable.