IShellLibrary::LoadLibraryFromKnownFolder method

Loads the library that is referenced by a KNOWNFOLDERID.

Syntax


HRESULT LoadLibraryFromKnownFolder(
  [in] REFKNOWNFOLDERID kfidLibrary,
  [in] DWORD            grfMode
);

Parameters

kfidLibrary [in]

Type: REFKNOWNFOLDERID

The KNOWNFOLDERID value that identifies the library to load.

grfMode [in]

Type: DWORD

One or more STGM storage medium flags that specify access and sharing modes for the library object.

Return value

Type: HRESULT

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

Remarks

If the IShellLibrary object contains a library when this method is called, that library is overwritten in memory with the new library.

If there is no existing IShellLibrary object for this library, SHLoadLibraryFromItem can be called in place of this method.

Examples

The following code example shows the helper function SHLoadLibraryFromKnownFolder, which wraps this method.


//
// from shobjidl.h
//
__inline HRESULT SHLoadLibraryFromKnownFolder(
    __in REFKNOWNFOLDERID kfidLibrary, 
    __in DWORD grfMode, 
    __in REFIID riid, 
    __deref_out void **ppv)
{
    *ppv = NULL;
    IShellLibrary *plib;
    HRESULT hr = CoCreateInstance( 
        CLSID_ShellLibrary,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_PPV_ARGS(&plib));
    if (SUCCEEDED(hr))
    {
        hr = plib->LoadLibraryFromKnownFolder(kfidLibrary, grfMode);
        if (SUCCEEDED(hr))
        {
            hr = plib->QueryInterface(riid, ppv);
        }
        plib->Release();
    }
    return hr;}

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Shobjidl.h

IDL

Shobjidl.idl

See also

Windows Libraries
IShellLibrary
IShellLibrary::LoadLibraryFromItem
SHCreateLibrary
SHLoadLibraryFromItem
SHLoadLibraryFromParsingName
SHLoadLibraryFromKnownFolder

 

 

Show: