コード例 #1
0
    public static HRESULT SHSaveLibraryInFolderPath(IShellLibrary *plib, [NativeTypeName("PCWSTR")] ushort *pszFolderPath, [NativeTypeName("PCWSTR")] ushort *pszLibraryName, LIBRARYSAVEFLAGS lsf, [NativeTypeName("PWSTR *")] ushort **ppszSavedToPath)
    {
        if ((ppszSavedToPath) != null)
        {
            *ppszSavedToPath = null;
        }

        IShellItem *psiFolder;
        HRESULT     hr = SHCreateItemFromParsingName(pszFolderPath, null, __uuidof <IShellItem>(), (void **)(&psiFolder));

        if ((((int)(hr)) >= 0))
        {
            IShellItem *psiSavedTo;

            hr = plib->Save(psiFolder, pszLibraryName, lsf, &psiSavedTo);
            if ((((int)(hr)) >= 0))
            {
                if ((ppszSavedToPath) != null)
                {
                    hr = psiSavedTo->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, ppszSavedToPath);
                }

                _ = psiSavedTo->Release();
            }

            _ = psiFolder->Release();
        }

        return(hr);
    }
コード例 #2
0
    public static HRESULT SHResolveFolderPathInLibrary(IShellLibrary *plib, [NativeTypeName("PCWSTR")] ushort *pszFolderPath, [NativeTypeName("DWORD")] uint dwTimeout, [NativeTypeName("PWSTR *")] ushort **ppszResolvedPath)
    {
        *           ppszResolvedPath = null;
        ITEMIDLIST *pidlFolder       = SHSimpleIDListFromPath(pszFolderPath);
        HRESULT     hr = unchecked ((pidlFolder) != null ? ((int)(0)) : ((int)(0x80070057)));

        if (((unchecked ((int)(hr))) >= 0))
        {
            IShellItem *psiFolder;

            hr = SHCreateItemFromIDList(pidlFolder, __uuidof <IShellItem>(), (void **)(&psiFolder));
            if (((unchecked ((int)(hr))) >= 0))
            {
                IShellItem *psiResolved;

                hr = plib->ResolveFolder(psiFolder, dwTimeout, __uuidof <IShellItem>(), (void **)(&psiResolved));
                if (((unchecked ((int)(hr))) >= 0))
                {
                    unchecked (hr) = psiResolved->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, ppszResolvedPath);
                    _ = psiResolved->Release();
                }

                _ = psiFolder->Release();
            }

            CoTaskMemFree(pidlFolder);
        }

        return(hr);
    }
コード例 #3
0
    public static HRESULT SHAddFolderPathToLibrary(IShellLibrary *plib, [NativeTypeName("PCWSTR")] ushort *pszFolderPath)
    {
        IShellItem *psiFolder;
        HRESULT     hr = SHCreateItemFromParsingName(pszFolderPath, null, __uuidof <IShellItem>(), (void **)(&psiFolder));

        if ((((int)(hr)) >= 0))
        {
            hr = plib->AddFolder(psiFolder);
            _  = psiFolder->Release();
        }

        return(hr);
    }
コード例 #4
0
    public static HRESULT SHRemoveFolderPathFromLibrary(IShellLibrary *plib, [NativeTypeName("PCWSTR")] ushort *pszFolderPath)
    {
        ITEMIDLIST *pidlFolder = SHSimpleIDListFromPath(pszFolderPath);
        HRESULT     hr         = unchecked ((pidlFolder) != null ? ((int)(0)) : ((int)(0x80070057)));

        if (((unchecked ((int)(hr))) >= 0))
        {
            IShellItem *psiFolder;

            unchecked (hr) = SHCreateItemFromIDList(pidlFolder, __uuidof <IShellItem>(), (void **)(&psiFolder));
            if (((unchecked ((int)(hr))) >= 0))
            {
                unchecked (hr) = plib->RemoveFolder(psiFolder);
                _ = psiFolder->Release();
            }

            CoTaskMemFree(pidlFolder);
        }

        return(hr);
    }