28 #include <nsILocalFile.h>
29 #include <nsStringGlue.h>
32 #if defined(_WIN32_WINNT)
34 #define _WIN32_WINNT 0x0600 //Windows Vista or Greater
39 #define SB_WIN_ENSURE_SUCCESS(aHR, aRV) \
53 sbKnownFolderManager::~sbKnownFolderManager()
62 NS_ENSURE_TRUE(SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE, NS_ERROR_FAILURE);
63 NS_WARN_IF_FALSE(SUCCEEDED(hr),
"RPC_E_CHANGED_MODE on COM initialization");
65 nsRefPtr<IKnownFolderManager> knownFolderManager;
66 hr = ::CoCreateInstance(CLSID_KnownFolderManager,
69 IID_IKnownFolderManager,
70 getter_AddRefs(knownFolderManager));
80 nsAString &aDisplayName)
82 nsCOMPtr<nsILocalFile> localFile;
83 nsresult rv = NS_NewLocalFile(aFolderPath,
85 getter_AddRefs(localFile));
86 NS_ENSURE_SUCCESS(rv, rv);
88 rv = localFile->GetLeafName(aDisplayName);
89 NS_ENSURE_SUCCESS(rv, rv);
95 sbKnownFolderManager::GetDisplayNameFromPath(
const nsAString &aFolderPath,
96 nsAString &aDisplayName)
100 NS_ENSURE_SUCCESS(rv, rv);
117 nsRefPtr<IKnownFolder> knownFolder;
121 getter_AddRefs(knownFolder));
124 nsRefPtr<IShellItem> shellItem;
125 hr = knownFolder->GetShellItem(0, IID_IShellItem, getter_AddRefs(shellItem));
128 LPWSTR displayName = NULL;
129 hr = shellItem->GetDisplayName(SIGDN_NORMALDISPLAY, &displayName);
132 nsDependentString tempStr(displayName);
133 aDisplayName.Assign(tempStr);
135 ::CoTaskMemFree(displayName);
HRESULT Initialize(DWORD aInitFlags=COINIT_MULTITHREADED)
sbAutoCOMInitializer mCOMInit
nsRefPtr< IKnownFolderManager > mKnownFolderManager
Manage Known Operating System Folders.
NS_DECL_ISUPPORTS NS_DECL_SBIKNOWNFOLDERMANAGER sbKnownFolderManager()
NS_IMPL_ISUPPORTS1(sbKnownFolderManager, sbIKnownFolderManager)
#define SB_WIN_ENSURE_SUCCESS(aHR, aRV)
nsresult GetDefaultDisplayName(const nsAString &aFolderPath, nsAString &aDisplayName)