This topic has not yet been rated - Rate this topic

SHCreateShellFolderView function

Applies to: desktop apps only

Creates a new instance of the default Shell folder view object (DefView).

Syntax

HRESULT SHCreateShellFolderView(
  __in   const SFV_CREATE *pcsfv,
  __out  IShellView **ppsv
);

Parameters

pcsfv [in]

Type: const SFV_CREATE*

Pointer to a SFV_CREATE structure that describes the particulars used in creating this instance of the Shell folder view object.

ppsv [out]

Type: IShellView**

When this function returns successfully, contains an interface pointer to the new IShellView object. On failure, this value is NULL.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

SHCreateShellFolderView is recommended over SHCreateShellFolderViewEx because of the greater flexibility of its elements to participate in various scenarios, provide new functionality to the view, and interact with other objects.

When dealing with several instances of IShellView, you might want to verify which is the default Shell folder view object. To do so, call QueryInterface on the object using the IID_CDefView IID. This call succeeds only when made on the default Shell folder view object.

Data sources that use the default Shell folder view object must implement these interfaces:

Optionally, they can also implement IPersistFolder3.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Shlobj.h

Library

Shell32.lib

DLL

Shell32.dll (version 5.0 or later)

See also

SFV_CREATE
SHCreateShellFolderViewEx

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
This API fails on Win7

This API fails on win7 with returned value 0x80070002(ERROR_FILE_NOT_FOUND). I used process monitor to trace registry and file system operations during the calling, but no such operation performed at all. I have struggling with this issue for several days but with no solution, and I don't know what this error really means(Which file not found or which registry key not found). Our project has been blocked for the failure of this API.

The issue mentioned above has been solved, it has something to do with the implementation of IShellFolder2::GetCurFolder().



IShellFolder2 is required
It's not stated here but under Vista (and perhaps also in earlier versions) SHCreateShellFolderView will return E_NOINTERFACE if the folder passed in the SFV_CREATE doesn't implement IShellFolder2. This blog post mentions this: http://shellrevealed.com/blogs/shellblog/archive/2007/03/15/Shell-Namespace-Extension_3A00_-Creating-and-Using-the-System-Folder-View-Object.aspx
IPersistFolder2 is also required
I have noted that IShellFolder2 is not enough under 7even.
You need to implement IPersistFolder2 as well.