自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Windows 7編程新特性Shell Library接口介紹

系統(tǒng)
目前看來很多Windows 7編程新特性都是圍繞.NET平臺進(jìn)行的,畢竟都是微軟一家的東西。

目前看來很多Windows 7編程新特性都是圍繞.NET平臺進(jìn)行的,畢竟都是微軟一家的東西。

  下文所用到的示例代碼來源于微軟一站式開發(fā)技術(shù)框架解決方案。你可以通過http://cfx.codeplex.com/Release/ProjectReleases.aspx下載到Windows7ShellLibrary相關(guān)的sample。其中包含C++、C#、VB.NET對ShellLibrary操作的示例代碼:CppWin7ShellLibrary,C#Win7ShellLibrary,VBWin7ShellLibrary。

  為了幫助用戶更加有效地對硬盤上的文件進(jìn)行管理,Windows7中引入了新的文件管理方式:庫(Library)。庫自然演化自以往操作系統(tǒng)中MyDocuments文件夾這個概念。有了庫,我們就可以將多個相關(guān)的文件夾組織到同一個庫下,從而更快更便捷地管理和搜索數(shù)據(jù)。

  創(chuàng)建Windows Shell Library

  Windows 7提供了SHCreateLibrary API用來創(chuàng)建一個Shell Library:

  C++ CreateShellLibrary /**//*! * Create a new shell libraryunderthe users Libraries folder. if a library *with the same namealready exists, the new one overrides theexisting one. * * \parampwszLibraryName * The name of the shelllibrary to be created. */BOOLCreateShellLibrary( LPWSTR pwszLibraryName){/**////////////////////////////////////////////////////////////////////////////Create the shell library COM object. // IShellLibrary* pShellLib=NULL; HRESULT hr =SHCreateLibrary(IID_PPV_ARGS(&pShellLib)); if(FAILED(hr)) {_tprintf(_T(SHCreateLibrary failed to create theshell library )\ _T(COM object w/err 0x%08lx\n), hr);returnjiacubiaoj ijiacubiaoj ifalse;}/**///////////////////////////////////////////////////////////////////////////Save the new library under the users Libraries folder.//IShellItem* pSavedTo = NULL; hr=pShellLib->SaveInKnownFolder(FOLDERID_UsersLibraries,pwszLibraryName,LSF_OVERRIDEEXISTING, &pSavedTo); if (FAILED(hr)){_tprintf(_T(IShellLibrary::SaveInKnownFolder failed to save the)\ _T(library w/err 0x%08lx\n), hr); returnjiacubiaojijiacubiaoj ifalse;}/**////////////////////////////////////////////////////////////////////////////Clean up. // if (pShellLib != NULL)pShellLib->Release(); if(pSavedTo !=NULL) pSavedTo->Release(); return true;}/**////////////////////////////////////////////////////////////////////////Create a shell library. // using (ShellLibrary library =newShellLibrary(libraryName, true)) { }

  管理Windows Shell Library

  你可以通過調(diào)用SHShowManageLibraryUI API顯示出Windows標(biāo)準(zhǔn)的ShellLibrary管理對話框。值得注意的是,在調(diào)用SHShowManageLibraryUI前請確保shelllibrary沒有被以可寫方式打開。否則在SHShowManageLibraryUI中對shelllibrary的修改將無法被保存。

  C++ ShowManageLibraryUI

  C++ ShowManageLibraryUI

  /**//*!

  * Shows the library management dialog box of thespec ifiedlibrary, which

  * enables users to manage the library folders and defaultsavelocation.

  *

  * \param pwszLibraryName

  * The name of the shell library

  */

  BOOL ShowManageLibraryUI( LPWSTR pwszLibraryName)

  {

  // Get the shell item that represents the library.

  IShellItem2* pShellItem=GetShellLibraryItem(pwszLibraryName);

  HRESULT hr = SHShowManageLibraryUI(pShellItem, NULL,

  LCppWin7ShellLibrary, LManage Library foldersandsettings,

  LMD_ALLOWUNINDEXABLENETWORKLOCATIONS);

  // Clean up

  if (pShellItem != NULL)

  pShellItem->Release();

  return SUCCEEDED(hr);

  }

  C# ShowManageLibraryUI

  // ShowManageLibraryUI requires that the library isnotcurrently

  // opened with write permission.

  ShellLibrary.ShowManageLibraryUI(libraryName, IntPtr.Zero,

  CSWin7ShellLibrary, Manage Library folders and settings,true);

  向Shell Library中添加文件夾

  SHAddFolderPathToLibrary可用來向指定的Shell Library中添加文件夾。

  C++ AddFolderToShellLibrary

  /**//*!

  * Add a folder to an existing shell library.

  *

  * \param pShellLib

  * The IShellLibrary interface of the shell library

  *

  * \param pwszFolderPath

  * The path of the folder to be added into the shell library

  *

  * \param bSaveLocation

  * if bSaveLocation is true, set thefolder as the save location ofthe shell

  * library

  */

  BOOL AddFolderToShellLibrary(IShellLibrary* pShellLib,

  LPWSTR pwszFolderPath, BOOL bSaveLocation)

  {

  HRESULT hr =SHAddFolderPathToLibrary(pShellLib,pwszFolderPath);

  if (FAILED(hr))

  {

  _tprintf(_T(SHAddFolderPathToLibrary failed to add a folder)\

  _T(to the shell library w/err 0x%08lx\n), hr);

  return jiacubiaoj ijiacubiaoj ifalse;

  }

  // Save the folder as the save location of the shell library

  if (bSaveLocation)

  {

  // Create shell item from folder path

  IShellItem2* pShellItemSaveFolder = NULL;

  hr = SHCreateItemFromParsingName(pwszFolderPath, 0,

  IID_PPV_ARGS(&pShellItemSaveFolder));

  if (FAILED(hr))

  {

  _tprintf(_T(SHCreateItemFromParsingName failed w/err ) \

  _T(0x%08lx\n), hr);

  return jiacubiaoj ijiacubiaoj ifalse;

  }

  // Set the folder as the save location

  pShellLib->SetDefaultSaveFolder(DSFT_DETECT,pShellItemSaveFolder);

  if (pShellItemSaveFolder != NULL)

  pShellItemSaveFolder->Release();

  if (FAILED(hr))

  {

  _tprintf(_T(IShellLibrary::SetDefaultSaveFolder failed ) \

  _T(w/err 0x%08lx\n), hr);

  return jiacubiaoj ijiacubiaoj ifalse;

  }

  }

  // Commit the change of the shell library

  pShellLib->Commit();

  return true;

  }

  C# AddFolderToShellLibrary

  using (ShellLibrary library =ShellLibrary.Load(libraryName,jiacubiaoj ijiacubiaoj ifalse))

  {

  /**//////////////////////////////////////////////////////////////////

  // Add a folder to the shell library.

  //

  // Add the folder to the shell library

  library.Add(folderPath);

  library.DefaultSaveFolder = folderPath;

  }

  枚舉Shell Library中的文件夾

  IShellLibrary::GetFolders可用來得到Shell Library中的文件夾。

  刪除一個Shell Library

  Windows 7編程新特性Shell Library接口介紹就到這里吧。

【編輯推薦】

  1. Windows 7多核評測:究竟快了多少?
  2. Linux之父Linus向Windows 7豎起大拇指
  3. 微軟證實Windows 7下載版升級遇到問題
責(zé)任編輯:龐桂玉 來源: Zol
相關(guān)推薦

2009-09-04 15:26:20

Windows 7編程

2009-08-28 08:46:15

Windows 7防火墻

2011-04-19 18:42:54

Windows Emb特性

2010-06-04 18:19:24

Windows Emb微軟嵌入式Windows Emb

2009-06-21 13:28:10

2010-11-24 16:36:02

Windows PhoUI設(shè)計Windows Pho

2021-04-30 19:53:41

Java表達(dá)式代碼

2012-03-14 12:29:55

JavaPlay Framwo

2013-03-25 11:34:27

Windows Blu

2010-10-08 09:54:30

IBM AIX 7

2009-05-25 08:56:26

Windows 7壁紙硬件

2009-08-12 13:15:44

C#3.5新特性

2011-07-06 16:38:57

Xcode Preview

2009-08-18 17:03:49

C#3.5新特性

2009-03-24 11:54:12

2021-03-06 08:10:16

Redis6 Java架構(gòu)分布式框架

2017-01-09 16:25:55

Android Shortcuts系統(tǒng)

2009-08-19 16:51:14

C# 4.0 dyna

2013-04-09 12:59:21

WindowsPhon

2009-12-23 18:58:51

Fedora 7
點贊
收藏

51CTO技術(shù)棧公眾號