WEB开发网
开发学院操作系统Windows 7 Windows 7 新特性 Shell Library 编程接口介绍 阅读

Windows 7 新特性 Shell Library 编程接口介绍

 2009-09-04 00:00:00 来源:WEB开发网   
核心提示: C# ListFoldersInShellLibraryusing (ShellLibrary library = ShellLibrary.Load(libraryName, false)){ /**// // List all folders in the library. // fore

C# ListFoldersInShellLibrary

using (ShellLibrary library = ShellLibrary.Load(libraryName, false))
{
    /**//////////////////////////////////////////////////////////////////
    // List all folders in the library.
    //

    foreach (ShellFolder folder in library)
    {
        Console.WriteLine(folder);
    }
}

删除一个Shell Library

C++ DeleteShellLibrary

/**//*!
* Delete the shell library under the user's Libraries folder according to the
* specified library name.
*
* \param pwszLibraryName
* The name of the shell library to be deleted.
*/
BOOL DeleteShellLibrary(LPWSTR pwszLibraryName)
{
    /**//////////////////////////////////////////////////////////////////////////
    // Get the shell item that represents the library and its full path.
    //

    IShellItem2* pShellItem = GetShellLibraryItem(pwszLibraryName);

    // Get the file-system full path of the shell item
    LPWSTR wszLibraryFullPath;
    pShellItem->GetString(PKEY_ParsingPath, &wszLibraryFullPath);


    /**//////////////////////////////////////////////////////////////////////////
    // Delete file with the library file-system based full path.
    //

    BOOL bSuccess = DeleteFileW(wszLibraryFullPath);

    // Clean up
    CoTaskMemFree(wszLibraryFullPath);
    if (pShellItem != NULL)
        pShellItem->Release();

    return bSuccess;
}

C# DeleteShellLibrary

/**//////////////////////////////////////////////////////////////////////
// Delete the shell library.
//

string librariesPath = Path.Combine(Environment.GetFolderPath(
    Environment.SpecialFolder.ApplicationData),
    ShellLibrary.LibrariesKnownFolder.RelativePath);

string libraryPath = Path.Combine(librariesPath, libraryName);
string libraryFullPath = Path.ChangeExtension(libraryPath, "library-ms");

File.Delete(libraryFullPath); 

更多关于Windows 7 Shell Library的操作请参见CppWin7ShellLibrary, CSWin7ShellLibrary和VBWin7ShellLibrary示例。

上一页  1 2 3 4 5 

Tags:Windows 特性 Shell

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接