当前位置: 首页>>代码示例>>C++>>正文


C++ IShellItem::Release方法代码示例

本文整理汇总了C++中IShellItem::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellItem::Release方法的具体用法?C++ IShellItem::Release怎么用?C++ IShellItem::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShellItem的用法示例。


在下文中一共展示了IShellItem::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetDefaultPath

static nfdresult_t SetDefaultPath( IFileDialog *dialog, const char *defaultPath )
{
    if ( !defaultPath || strlen(defaultPath) == 0 )
        return NFD_OKAY;

    wchar_t *defaultPathW = {0};
    CopyNFDCharToWChar( defaultPath, &defaultPathW );

    IShellItem *folder;
    HRESULT result = SHCreateItemFromParsingName( defaultPathW, NULL, IID_PPV_ARGS(&folder) );

    // Valid non results.
    if ( result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || result == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE) )
    {
        NFDi_Free( defaultPathW );
        return NFD_OKAY;
    }

    if ( !SUCCEEDED(result) )
    {
        NFDi_SetError("Error creating ShellItem");
        NFDi_Free( defaultPathW );
        return NFD_ERROR;
    }
    
    // Could also call SetDefaultFolder(), but this guarantees defaultPath -- more consistency across API.
    dialog->SetFolder( folder );

    NFDi_Free( defaultPathW );
    folder->Release();
    
    return NFD_OKAY;
}
开发者ID:kjoshi,项目名称:nativefiledialog,代码行数:33,代码来源:nfd_win.cpp

示例2: PyCom_BuildPyException

// @pymethod (int, <o PyIShellItem>|PyITransferSource|RecycleItem|Moves an item to the recycle bin
PyObject *PyITransferSource::RecycleItem(PyObject *self, PyObject *args)
{
	ITransferSource *pITS = GetI(self);
	if ( pITS == NULL )
		return NULL;
	// @pyparm <o PyIShellItem>|Source||The item to be recycled
	// @pyparm <o PyIShellItem>|ParentDest||Shell item representing the recycle bin
	TRANSFER_SOURCE_FLAGS flags;
	// @pyparm int|flags||Combination of shellcon.TSF_* flags
	PyObject *obpsiSource;
	PyObject *obpsiParentDest;
	IShellItem * psiSource;
	IShellItem * psiParentDest;
	IShellItem * ppsiNewDest;
	if ( !PyArg_ParseTuple(args, "OOi:RecycleItem", &obpsiSource, &obpsiParentDest, &flags) )
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDest, IID_IShellItem, (void **)&psiParentDest, FALSE)){
		PYCOM_RELEASE(psiSource);
		return NULL;
		}
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pITS->RecycleItem( psiSource, psiParentDest, flags, &ppsiNewDest );
	psiSource->Release();
	psiParentDest->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pITS, IID_ITransferSource );
	return Py_BuildValue("lO", hr, PyCom_PyObjectFromIUnknown(ppsiNewDest, IID_IShellItem, FALSE));
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:34,代码来源:PyITransferSource.cpp

示例3: GetTargetData

HRESULT ComposerShellMenu::GetTargetData()
{
    IShellItem* item = NULL;
    BOOLEAN isFile = false;
    HRESULT hr = GetShellItem(&item, &isFile);
    
    if (SUCCEEDED(hr))
    {
        if (isFile)
        {
            IShellItem* parent = NULL;
            hr = GetShellItemParent(item, &parent);

            if (SUCCEEDED(hr))
            {
                hr = this->GetDataFromShellItem(parent);
                parent->Release();
            }
        }
        else
        {
            hr = this->GetDataFromShellItem(item);
        }
        
        item->Release();
    }

    return hr;
}
开发者ID:AlexRee,项目名称:windows-setup,代码行数:29,代码来源:menu.cpp

示例4: CoCreateInstance

std::vector<std::wstring> APlayerWindow::showOpenFile()
{
	HRESULT hr = S_OK;
	std::vector<std::wstring> filePaths;

	IFileOpenDialog *fileDlg = NULL;
	hr = CoCreateInstance(CLSID_FileOpenDialog,
		NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&fileDlg));
	if (FAILED(hr)) return filePaths;
	ON_SCOPE_EXIT([&] { fileDlg->Release(); });

	IKnownFolderManager *pkfm = NULL;
	hr = CoCreateInstance(CLSID_KnownFolderManager,
		NULL,
		CLSCTX_INPROC_SERVER,
		IID_PPV_ARGS(&pkfm));
	if (FAILED(hr)) return filePaths;
	ON_SCOPE_EXIT([&] { pkfm->Release(); });

	IKnownFolder *pKnownFolder = NULL;
	hr = pkfm->GetFolder(FOLDERID_PublicMusic, &pKnownFolder);
	if (FAILED(hr)) return filePaths;
	ON_SCOPE_EXIT([&] { pKnownFolder->Release(); });

	IShellItem *psi = NULL;
	hr = pKnownFolder->GetShellItem(0, IID_PPV_ARGS(&psi));
	if (FAILED(hr)) return filePaths;
	ON_SCOPE_EXIT([&] { psi->Release(); });

	hr = fileDlg->AddPlace(psi, FDAP_BOTTOM);
	COMDLG_FILTERSPEC rgSpec[] = {
		{ L"ÒôÀÖÎļþ", SupportType }
	};
	fileDlg->SetFileTypes(1, rgSpec);

	DWORD dwOptions;
	fileDlg->GetOptions(&dwOptions);
	fileDlg->SetOptions(dwOptions | FOS_ALLOWMULTISELECT);
	hr = fileDlg->Show(NULL);
	if (SUCCEEDED(hr)) {
		IShellItemArray *pRets;
		hr = fileDlg->GetResults(&pRets);
		if (SUCCEEDED(hr)) {
			DWORD count;
			pRets->GetCount(&count);
			for (DWORD i = 0; i < count; i++) {
				IShellItem *pRet;
				LPWSTR nameBuffer;
				pRets->GetItemAt(i, &pRet);
				pRet->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &nameBuffer);
				filePaths.push_back(std::wstring(nameBuffer));
				pRet->Release();
				CoTaskMemFree(nameBuffer);
			}
			pRets->Release();
		}
	}
	return filePaths;
}
开发者ID:wyrover,项目名称:MusicPlayer,代码行数:59,代码来源:APlayerWindow.cpp

示例5: v_ExecuteLibCommand

    HRESULT v_ExecuteLibCommand()
    {
        // Get the private and public save locations.
        IShellItem *psiPrivateSaveLoc;
        HRESULT hr = _plib->GetDefaultSaveFolder(DSFT_PRIVATE, IID_PPV_ARGS(&psiPrivateSaveLoc));
        if (SUCCEEDED(hr))
        {
            IShellItem *psiPublicSaveLoc;
            hr = _plib->GetDefaultSaveFolder(DSFT_PUBLIC, IID_PPV_ARGS(&psiPublicSaveLoc));
            if (SUCCEEDED(hr))
            {
                // Get the list of folders that match the specified filter.
                IShellItemArray *psiaFolders;
                hr = _plib->GetFolders(_lffFilter, IID_PPV_ARGS(&psiaFolders));
                if (SUCCEEDED(hr))
                {
                    DWORD cFolders;
                    hr = psiaFolders->GetCount(&cFolders);
                    if (SUCCEEDED(hr))
                    {
                        Output(L"Library contains %u folders:\n", cFolders);
                        for (DWORD iFolder = 0; iFolder < cFolders; iFolder++)
                        {
                            IShellItem *psiFolder;
                            if (SUCCEEDED(psiaFolders->GetItemAt(iFolder, &psiFolder)))
                            {
                                // Print each folder's name as an absolute path, suitable for parsing in the Shell Namespace (e.g SHParseDisplayName).
                                // For file system folders (the typical case), this will be the file system path of the folder.
                                PWSTR pszDisplay;
                                if (SUCCEEDED(psiFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszDisplay)))
                                {
                                    PCWSTR pszPrefix = L"  ";
                                    int iCompare;
                                    if (S_OK == psiPrivateSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
                                    {
                                        pszPrefix = L"* ";
                                    }
                                    else if (S_OK == psiPublicSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
                                    {
                                        pszPrefix = L"# ";
                                    }

                                    Output(L"%s%s\n", pszPrefix, pszDisplay);
                                    CoTaskMemFree(pszDisplay);
                                }
                                psiFolder->Release();
                            }
                        }
                    }
                    psiaFolders->Release();
                }
                psiPublicSaveLoc->Release();
            }
            psiPrivateSaveLoc->Release();
        }
        return hr;
    }
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:57,代码来源:ShellLibraryCommandLine.cpp

示例6: fileOpenDialog

extern "C" LXCWIN_API HRESULT fileOpenDialog(HWND hWnd, DWORD *count, LPWSTR **result) {
    *result = NULL;
    HRESULT hr = S_OK;
    CoInitialize(nullptr);
    IFileOpenDialog *pfd = NULL;
    hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
    if (SUCCEEDED(hr)) {
        // set default folder to "My Documents"
        IShellItem *psiDocuments = NULL;
        hr = SHCreateItemInKnownFolder(FOLDERID_Documents, 0, NULL,
                                       IID_PPV_ARGS(&psiDocuments));
        if (SUCCEEDED(hr)) {
            hr = pfd->SetDefaultFolder(psiDocuments);
            psiDocuments->Release();
        }

        // dialog title
        pfd->SetTitle(L"Select files to share");

        // allow multiselect, restrict to real files
        DWORD dwOptions;
        hr = pfd->GetOptions(&dwOptions);
        if (SUCCEEDED(hr)) {
            // ideally, allow selecting folders as well as files, but IFileDialog does not support this :(
            pfd->SetOptions(dwOptions | FOS_ALLOWMULTISELECT | FOS_FORCEFILESYSTEM); // | FOS_PICKFOLDERS
        }

        // do not limit to certain file types

        // show the open file dialog
        hr = pfd->Show(hWnd);
        if (SUCCEEDED(hr)) {
            IShellItemArray *psiaResults;
            hr = pfd->GetResults(&psiaResults);
            if (SUCCEEDED(hr)) {
                hr = psiaResults->GetCount(count);
                if (SUCCEEDED(hr)) {
                    *result = (LPWSTR*)calloc(*count, sizeof(LPWSTR));
                    if (*result != NULL) {
                        for (DWORD i = 0; i < *count; i++) {
                            IShellItem *resultItem = NULL;
                            hr = psiaResults->GetItemAt(i, &resultItem);
                            if (SUCCEEDED(hr)) {
                                resultItem->GetDisplayName(SIGDN_FILESYSPATH, &((*result)[i]));
                                resultItem->Release();
                            }
                        }
                        // paths now contains selected files
                    }
                }
                psiaResults->Release();
            }
        }
        pfd->Release();
    }
    return hr;
}
开发者ID:tfg13,项目名称:LanXchange,代码行数:57,代码来源:lxcwin.cpp

示例7: SetSelection

  // IObjectWithSelection
  IFACEMETHODIMP SetSelection(IShellItemArray *aArray)
  {
    if (!aArray) {
      return E_FAIL;
    }

    SetInterface(&mShellItemArray, aArray);

    DWORD count = 0;
    aArray->GetCount(&count);
    if (!count) {
      return E_FAIL;
    }

#ifdef SHOW_CONSOLE
    Log(L"SetSelection param count: %d", count);
    for (DWORD idx = 0; idx < count; idx++) {
      IShellItem* item = nullptr;
      if (SUCCEEDED(aArray->GetItemAt(idx, &item))) {
        LPWSTR str = nullptr;
        if (FAILED(item->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
          if (FAILED(item->GetDisplayName(SIGDN_URL, &str))) {
            Log(L"Failed to get a shell item array item.");
            item->Release();
            continue;
          }
        }
        item->Release();
        Log(L"SetSelection param: '%s'", str);
        CoTaskMemFree(str);
      }
    }
#endif

    IShellItem* item = nullptr;
    if (FAILED(aArray->GetItemAt(0, &item))) {
      return E_FAIL;
    }

    bool isFileSystem = false;
    if (!SetTargetPath(item) || !mTarget.GetLength()) {
      Log(L"SetTargetPath failed.");
      return E_FAIL;
    }
    item->Release();

    Log(L"SetSelection target: %s", mTarget);
    return S_OK;
  }
开发者ID:mvujovic,项目名称:gecko-dev,代码行数:50,代码来源:CommandExecuteHandler.cpp

示例8: PyCom_BuildPyException

// @pymethod |PyIShellLibrary|SetDefaultSaveFolder|Sets the default save location
PyObject *PyIShellLibrary::SetDefaultSaveFolder(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	DEFAULTSAVEFOLDERTYPE Type;
	IShellItem *SaveFolder;
	PyObject *obSaveFolder;
	// @pyparm int|Type||Specifies public or private save location, shellcon.DSFT_*
	// @pyparm <o PyIShellItem>|SaveFolder||New default location, must be in the library
	if (!PyArg_ParseTuple(args, "iO:SetDefaultSaveFolder", &Type, &obSaveFolder))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obSaveFolder, IID_IShellItem, (void **)&SaveFolder, FALSE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->SetDefaultSaveFolder(Type, SaveFolder);
	SaveFolder->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:27,代码来源:PyIShellLibrary.cpp

示例9: DisplayItems

HRESULT ContextMenu::DisplayItems(IShellItemArray *psia, HWND hwndParent)
{
	DWORD count;
	psia->GetCount(&count);

	for(DWORD i = 0; i < count; ++i)
	{
	    IShellItem *psi;
		HRESULT hr = psia->GetItemAt(i, &psi);
		if (SUCCEEDED(hr))
		{
			PWSTR pszDisplayName;
			hr = psi->GetDisplayName(SIGDN_NORMALDISPLAY, &pszDisplayName);
			if (SUCCEEDED(hr))
			{
				MessageBoxW(hwndParent, pszDisplayName, pszDisplayName, MB_OK);
				CoTaskMemFree(pszDisplayName);
			}
			psi->Release();
		}
		else
		{
			return hr;
		}
    }  

    return S_OK;
}
开发者ID:UrsusHorribilis,项目名称:simpleshare,代码行数:28,代码来源:contextmenu.cpp

示例10: addIconFromShellFactory

// On Vista or 7 we could use SHIL_JUMBO to get a 256x256 icon,
// but we'll use SHCreateItemFromParsingName as it'll give an identical
// icon to the one shown in explorer and it scales automatically.
bool WinIconProvider::addIconFromShellFactory(QString filePath, QIcon& icon) const
{
	HRESULT hr = S_FALSE;

	if (fnSHCreateItemFromParsingName)
	{
		IShellItem* psi = NULL;
        hr = fnSHCreateItemFromParsingName((PCWSTR)filePath.utf16(), 0, IID_IShellItem, (void**)&psi);
		if (hr == S_OK)
		{
			IShellItemImageFactory* psiif = NULL;
			hr = psi->QueryInterface(IID_IShellItemImageFactory, (void**)&psiif);
			if (hr == S_OK)
			{
				HBITMAP iconBitmap = NULL;
				SIZE iconSize = {preferredSize, preferredSize};
				hr = psiif->GetImage(iconSize, SIIGBF_RESIZETOFIT | SIIGBF_ICONONLY, &iconBitmap);
				if (hr == S_OK)
				{
                    QPixmap iconPixmap = QtWin::fromHBITMAP(iconBitmap);
					icon.addPixmap(iconPixmap);
					DeleteObject(iconBitmap);
				}

				psiif->Release();
			}
			psi->Release();
		}
	}

	return hr == S_OK;
}
开发者ID:Slesa,项目名称:launchy,代码行数:35,代码来源:win_Iconprovider.cpp

示例11: PyCom_BuildPyException

// @pymethod |PyINameSpaceTreeControl|AppendRoot|Description of AppendRoot.
PyObject *PyINameSpaceTreeControl::AppendRoot(PyObject *self, PyObject *args)
{
	INameSpaceTreeControl *pINSTC = GetI(self);
	if ( pINSTC == NULL )
		return NULL;
	// @pyparm <o PyIShellItem>|psiRoot||Description for psiRoot
	// @pyparm int|grfEnumFlags||Description for grfEnumFlags
	// @pyparm int|grfRootStyle||Description for grfRootStyle
	// @pyparm <o PyIShellItemFilter>|pif||Description for pif
	PyObject *obpsiRoot;
	PyObject *obpif;
	IShellItem * psiRoot;
	DWORD grfEnumFlags;
	DWORD grfRootStyle;
	IShellItemFilter * pif;
	if ( !PyArg_ParseTuple(args, "OkkO:AppendRoot", &obpsiRoot, &grfEnumFlags, &grfRootStyle, &obpif) )
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiRoot, IID_IShellItem, (void **)&psiRoot, TRUE /* bNoneOK */))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpif, IID_IShellItemFilter, (void **)&pif, TRUE /* bNoneOK */)) {
		if (pif) pif->Release();
		return NULL;
	}
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pINSTC->AppendRoot( psiRoot, grfEnumFlags, grfRootStyle, pif );
	if (psiRoot) psiRoot->Release();
	if (pif) pif->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pINSTC, IID_INameSpaceTreeControl );
	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:35,代码来源:PyINameSpaceTreeControl.cpp

示例12: PyCom_BuildPyException

// @pymethod int|PyIShellItem|Compare|Compares another shell item with this item
// @rdesc Returns 0 if items compare as equal, nonzero otherwise
PyObject *PyIShellItem::Compare(PyObject *self, PyObject *args)
{
	IShellItem *pISI = GetI(self);
	if ( pISI == NULL )
		return NULL;
	// @pyparm <o PyIShellItem>|psi||A shell item to be compared with this item
	SICHINTF hint;
	// @pyparm int|hint||shellcon.SICHINT_* value indicating how the comparison is to be performed
	PyObject *obpsi;
	IShellItem *psi;
	if ( !PyArg_ParseTuple(args, "Oi:Compare", &obpsi, &hint) )
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpsi, IID_IShellItem, (void **)&psi, FALSE))
		return NULL;
	HRESULT hr;
	int iOrder;
	PY_INTERFACE_PRECALL;
	hr = pISI->Compare( psi, hint, &iOrder );
	psi->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISI, IID_IShellItem );
	return PyInt_FromLong(iOrder);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:27,代码来源:PyIShellItem.cpp

示例13: PickContainer

void PickContainer()
{
    IFileDialog *pfd;
    if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
    {
        DWORD dwOptions;
        if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
        {
            pfd->SetOptions(dwOptions | FOS_PICKFOLDERS);
        }

        if (SUCCEEDED(pfd->Show(NULL)))
        {
            IShellItem *psi;
            if (SUCCEEDED(pfd->GetResult(&psi)))
            {
                PWSTR pszPath;
                if (SUCCEEDED(GetIDListName(psi, &pszPath)))
                {
                    MessageBox(NULL, pszPath, L"Selected Container", MB_OK);
                    CoTaskMemFree(pszPath);
                }
                psi->Release();
            }
        }
        pfd->Release();
    }
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:28,代码来源:CommonFileDialogModes.cpp

示例14: LoadFile

PWSTR LoadFile() {
	IFileOpenDialog *pFileOpen;
	PWSTR pszFilePath = NULL;

	// Create the FileOpenDialog object.
	HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
		IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
	if (SUCCEEDED(hr))
	{
		//IShellItem *psiDocuments = NULL;
		//hr = SHCreateItemInKnownFolder(FOLDERID_Documents, 0, NULL, IID_PPV_ARGS(&psiDocuments));

		//if (SUCCEEDED(hr)) {
		//	hr = pFileOpen->SetFolder(psiDocuments);
		//	psiDocuments->Release();
		//}
		// Show the Open dialog box.
		hr = pFileOpen->Show(NULL);

		// Get the file name from the dialog box.
		if (SUCCEEDED(hr))
		{
			IShellItem *pItem;
			hr = pFileOpen->GetResult(&pItem);
			if (SUCCEEDED(hr))
			{
				hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);

				pItem->Release();
			}
		}
		pFileOpen->Release();
	}
	return pszFilePath;
}
开发者ID:arbiter34,项目名称:Win32NES,代码行数:35,代码来源:Win32NES.cpp

示例15: getOpenDirectory

bool getOpenDirectory(char* out, int max_size, const char* starting_dir)
{
	bool ret = false;
	IFileDialog* pfd;
	if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
	{
		if (starting_dir)
		{
			PIDLIST_ABSOLUTE pidl;
			WCHAR wstarting_dir[MAX_PATH];
			WCHAR* wc = wstarting_dir;
			for (const char *c = starting_dir; *c && wc - wstarting_dir < MAX_PATH - 1; ++c, ++wc)
			{
				*wc = *c == '/' ? '\\' : *c;
			}
			*wc = 0;

			HRESULT hresult = ::SHParseDisplayName(wstarting_dir, 0, &pidl, SFGAO_FOLDER, 0);
			if (SUCCEEDED(hresult))
			{
				IShellItem* psi;
				hresult = ::SHCreateShellItem(NULL, NULL, pidl, &psi);
				if (SUCCEEDED(hresult))
				{
					pfd->SetFolder(psi);
				}
				ILFree(pidl);
			}
		}

		DWORD dwOptions;
		if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
		{
			pfd->SetOptions(dwOptions | FOS_PICKFOLDERS);
		}
		if (SUCCEEDED(pfd->Show(NULL)))
		{
			IShellItem* psi;
			if (SUCCEEDED(pfd->GetResult(&psi)))
			{
				WCHAR* tmp;
				if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &tmp)))
				{
					char* c = out;
					while (*tmp && c - out < max_size - 1)
					{
						*c = (char)*tmp;
						++c;
						++tmp;
					}
					*c = '\0';
					ret = true;
				}
				psi->Release();
			}
		}
		pfd->Release();
	}
	return ret;
}
开发者ID:gunsafighter,项目名称:LumixEngine,代码行数:60,代码来源:platform_interface.cpp


注:本文中的IShellItem::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。