Read / write a file in a shell namespace extension using shell APIs

668 views Asked by At

I've used SHGetDesktopFolder() to get a PIDL and then walked down it's contents using IShellFolder.

I now have a particular PIDL referencing a filesystem location, and I can use BindToStorage and IStorage to .OpenStream() and .Write() a file.

This is all well and good if the interesting things live on the filesystem, but more interesting things live in "Shell Namespace Extensions".

In particular, I have a Pocket PC 2002 device (Specificly, a Symbol PDT8146) that is hooked up to my Windows 7 machine using Windows Mobile Device Center. This application creates a shell namespace folder that I can use from within explorer to read/write files to it.

What I cannot do is write files to it using the command line or win32 APIs.

Following the strategy I outlined above, I can get a PIDL and IShellFolder instance referring to the device, and I can list it's files. However, IShellFolder.BindToStorage() fails with 'No such interface supported' when I try to access IStorage.

Is there another shell interface I should investigate to read/write files on this stubborn device?

1

There are 1 answers

2
ssbssa On

Try IShellFolder.BindToObject:

IStream *stream;
if (FAILED(shellfolder->BindToObject (pidl, NULL, IID_IStream, &stream)))
  return E_FAIL;

But I'm not sure if this works with writing files as well.