IShellFolder::BindToObject() problem

  • Thread starter Thread starter Melinda
  • Start date Start date
M

Melinda

hi all,

i'm having problems with BindToObject(). when i call the method it is
throwing a System.NullReferenceException error, but i don't understand
why. what i'm trying to do is get a reference to an IShellFolder for
a folder of a PIDL that i already have. i'm doing that using by
calling BindToObject() of the IShellFolder of the desktop folder, per
the documentation.

here is some code:

IShellFolder pIShellParent = null;
IShellFolder pIShellDesktop = ShellFunctions.GetDesktopFolder();
Guid IID_IShellFolder = typeof(IShellFolder).GUID;

// pidlParent is defined earlier
int hr = pIShellDesktop.BindToObject( pidlParent, IntPtr.Zero,
IID_IShellFolder, out pIShellParent );

i've gone thru this code with the debugger and i know that
pIShellDesktop is not null and pidlParent is not null. i'm stumped.
any help would be appreciated.

thanks,

melinda
 
Melinda,

How did you declare the method in the interface? It could be because
you're passing the guid by value.



Mattias
 
Mattias Sjögren said:
Melinda,

How did you declare the method in the interface? It could be because
you're passing the guid by value.



Mattias

thank you mattias! i was indeed passing the guid by value. i changed it to:
[In()] ref Guid riid
and the error went away.

thanks,

melinda
 
Back
Top