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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: ChangeDropImageType

	void ChangeDropImageType(DROPIMAGETYPE newType)
	{
		if (newType != _dropImageType) {
			_dropImageType = newType;
			if (_pdtobj != nullptr) {
				IShellItem *psi;
				HRESULT hr = CreateItemFromObject(_pdtobj, IID_PPV_ARGS(&psi));
				if (SUCCEEDED(hr))
				{
					PWSTR pszName;
					hr = psi->GetDisplayName(SIGDN_NORMALDISPLAY/*SIGDN_FILESYSPATH*/, &pszName);
					if (SUCCEEDED(hr))
					{
						SetDropTip(_pdtobj, _dropImageType, _pszDropTipTemplate ? _pszDropTipTemplate : L"%1", pszName);
						CoTaskMemFree(pszName);
					}
					psi->Release();
				}
				else {
					auto strName = GetDisplayFullNameFromObject(_pdtobj);
					if (!strName.IsEmpty()) {
						SetDropTip(_pdtobj, _dropImageType, _pszDropTipTemplate ? _pszDropTipTemplate : L"%1", strName);
					}
				}
			}
		}
	}
开发者ID:halx99,项目名称:OleDataDemo,代码行数:27,代码来源:PropertiesWnd.cpp

示例5: 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

示例6: 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

示例7: CoCreateInstance

char *commonItemDialog(HWND parent, REFCLSID clsid, REFIID iid, FILEOPENDIALOGOPTIONS optsadd)
{
	IFileDialog *d = NULL;
	FILEOPENDIALOGOPTIONS opts;
	IShellItem *result = NULL;
	WCHAR *wname = NULL;
	char *name = NULL;
	HRESULT hr;

	hr = CoCreateInstance(clsid,
		NULL, CLSCTX_INPROC_SERVER,
		iid, (LPVOID *) (&d));
	if (hr != S_OK) {
		logHRESULT(L"error creating common item dialog", hr);
		// always return NULL on error
		goto out;
	}
	hr = d->GetOptions(&opts);
	if (hr != S_OK) {
		logHRESULT(L"error getting current options", hr);
		goto out;
	}
	opts |= optsadd;
	// the other platforms don't check read-only; we won't either
	opts &= ~FOS_NOREADONLYRETURN;
	hr = d->SetOptions(opts);
	if (hr != S_OK) {
		logHRESULT(L"error setting options", hr);
		goto out;
	}
	hr = d->Show(parent);
	if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))
		// cancelled; return NULL like we have ready
		goto out;
	if (hr != S_OK) {
		logHRESULT(L"error showing dialog", hr);
		goto out;
	}
	hr = d->GetResult(&result);
	if (hr != S_OK) {
		logHRESULT(L"error getting dialog result", hr);
		goto out;
	}
	hr = result->GetDisplayName(SIGDN_FILESYSPATH, &wname);
	if (hr != S_OK) {
		logHRESULT(L"error getting filename", hr);
		goto out;
	}
	name = toUTF8(wname);

out:
	if (wname != NULL)
		CoTaskMemFree(wname);
	if (result != NULL)
		result->Release();
	if (d != NULL)
		d->Release();
	return name;
}
开发者ID:08opt,项目名称:libui,代码行数:59,代码来源:stddialogs.cpp

示例8:

bool Gwen::Platform::FolderOpen( const String& Name, const String& StartPath, Gwen::Event::Handler* pHandler, Event::Handler::FunctionWithInformation fnCallback )
{
	IFileDialog *pfd = NULL;
	bool bSuccess = false;

	if ( CoCreateInstance( CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS( &pfd ) ) != S_OK )
		return bSuccess;

	DWORD dwOptions;

	if ( pfd->GetOptions(&dwOptions) != S_OK )
	{
		pfd->Release();
		return bSuccess;
	}

	pfd->SetOptions( dwOptions | FOS_PICKFOLDERS );

	//
	// TODO: SetDefaultFolder -> StartPath
	//

	if ( pfd->Show(NULL) == S_OK )
	{
		IShellItem *psi;

		if ( pfd->GetResult(&psi) == S_OK )
		{
			WCHAR* strOut = NULL;

			if ( psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &strOut ) != S_OK )
			{
				return bSuccess;
			}

			//
			// GWEN callback - call it.
			//
			if ( pHandler && fnCallback )
			{
				Gwen::Event::Information info;
				info.Control		= NULL;
				info.ControlCaller	= NULL;
				info.String			= Gwen::Utility::UnicodeToString( strOut );

				(pHandler->*fnCallback)( info );
			}

			CoTaskMemFree( strOut );
			psi->Release();
			bSuccess = true;
		}
	}

	pfd->Release();

	return bSuccess;
}
开发者ID:CmPons,项目名称:angel2d,代码行数:58,代码来源:Windows.cpp

示例9: 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

示例10: OnTakePhoto

    void OnTakePhoto(HWND hwnd)
    {
        wchar_t filename[MAX_PATH];

        // Get the path to the Documents folder.
        IShellItem *psi = NULL;
        PWSTR pszFolderPath = NULL;

        HRESULT hr = SHCreateItemInKnownFolder(FOLDERID_Documents, 0, NULL, IID_PPV_ARGS(&psi));
        if (FAILED(hr))
        {
            goto done;
        }

        hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszFolderPath);
        if (FAILED(hr))
        {
            goto done;
        }

        // Construct a file name based on the current time.

        SYSTEMTIME time;
        GetLocalTime(&time);

        hr = StringCchPrintf(filename, MAX_PATH, L"MyPhoto%04u_%02u%02u_%02u%02u%02u.jpg",
            time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
        if (FAILED(hr))
        {
            goto done;
        }

        LPTSTR path = PathCombine(PhotoFileName, pszFolderPath, filename);
        if (path == NULL)
        {
            hr = E_FAIL;
            goto done;
        }

        hr = g_pEngine->TakePhoto(path);
        if (FAILED(hr))
        {
            goto done;
        }

        _SetStatusText(path);

done:
        SafeRelease(&psi);
        CoTaskMemFree(pszFolderPath);

        if (FAILED(hr))
        {
            ShowError(hwnd, IDS_ERR_PHOTO, hr);
        }
        UpdateUI(hwnd);
    }
开发者ID:Bhaal22,项目名称:RealtimeContourDetection,代码行数:57,代码来源:winmain.cpp

示例11: 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

示例12: select_file

const bool Core::select_file() {
	//Open file dialog, straight from https://msdn.microsoft.com/en-us/library/windows/desktop/ff485843(v=vs.85).aspx
	HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
	PWSTR pszFilePath = nullptr;

	if (SUCCEEDED(hr)) {
		IFileOpenDialog *pFileOpen;

		// Create the FileOpenDialog object.
		hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
			IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));

		if (SUCCEEDED(hr)) {
			//Boilerplate for only showing *.nes files in the dialog. See the MSDN docs more info.
			COMDLG_FILTERSPEC fileFilter;
			fileFilter.pszName = L"iNES";
			fileFilter.pszSpec = L"*.nes";

			pFileOpen->SetFileTypes(1, &fileFilter);
			pFileOpen->SetFileTypeIndex(1);
			pFileOpen->SetDefaultExtension(L"nes");

			// 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);

					if (SUCCEEDED(hr)) {
						logmsg("Opening file");
					} else {
						pszFilePath = nullptr;
					}
					pItem->Release();
				}
			}
			pFileOpen->Release();
		}
		CoUninitialize();
	}

	if (pszFilePath == nullptr) {
		alert_error("Unable to open file! File must have the extension \".nes\"");
		return false;
	}

	//Convert wchar_t string to char string
	std::size_t i;
	wcstombs_s(&i, fileSelection, pszFilePath, MAX_PATH);

	return true;
}
开发者ID:mgukowsky,项目名称:MAGSNES,代码行数:57,代码来源:Core.cpp

示例13: OnFileOpen

//  Open an audio/video file.
void OnFileOpen(HWND hwnd)
{
    IFileOpenDialog *pFileOpen = NULL;
    IShellItem *pItem = NULL;
    PWSTR pszFilePath = NULL;

    // Create the FileOpenDialog object.
    HRESULT hr = CoCreateInstance(__uuidof(FileOpenDialog), NULL, 
        CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFileOpen));
    if (FAILED(hr))
    {
        goto done;
    }

    // Show the Open dialog box.
    hr = pFileOpen->Show(NULL);
    if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))
    {
        // The user canceled the dialog. Do not treat as an error.
        hr = S_OK;
        goto done;
    }
    else if (FAILED(hr))
    {
        goto done;
    }

    // Get the file name from the dialog box.
    hr = pFileOpen->GetResult(&pItem);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
    if (FAILED(hr))
    {
        goto done;
    }

    // Display the file name to the user.
    hr = g_pPlayer->OpenURL(pszFilePath);
    if (SUCCEEDED(hr))
    {
        UpdateUI(hwnd, OpenPending);
    }

done:
    if (FAILED(hr))
    {
        NotifyError(hwnd, L"Could not open the file.", hr);
        UpdateUI(hwnd, Closed);
    }
    CoTaskMemFree(pszFilePath);
    SafeRelease(&pItem);
    SafeRelease(&pFileOpen);
}
开发者ID:TimSC,项目名称:wmf-video-player-example,代码行数:58,代码来源:winmain.cpp

示例14: OnFileOk

STDMETHODIMP COpenFileListener::OnFileOk(IFileDialog* pfd)
{
	IShellItemArray *psiaResults;
	IFileDialogCustomize *pfdc;
	HRESULT hr;
	IFileOpenDialog *fod;
	FILEINFO fileinfoTmp = {0};
	DWORD choice;

	fileinfoTmp.parentList = pFInfoList;

	hr = pfd->QueryInterface(IID_PPV_ARGS(&fod));

	if(SUCCEEDED(hr)) {
		hr = fod->GetSelectedItems(&psiaResults);

		if (SUCCEEDED(hr)) {
			DWORD fileCount;
			IShellItem *isi;
			LPWSTR pwsz = NULL;

			psiaResults->GetCount(&fileCount);
			for(DWORD i=0;i<fileCount;i++) {
				psiaResults->GetItemAt(i,&isi);
				isi->GetDisplayName(SIGDN_FILESYSPATH,&pwsz);
				isi->Release();
                fileinfoTmp.szFilename = pwsz;
				pFInfoList->fInfos.push_back(fileinfoTmp);
				CoTaskMemFree(pwsz);
			}
			psiaResults->Release();
		}
		fod->Release();
	}

	hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdc));

	if(SUCCEEDED(hr)) {
		hr = pfdc->GetSelectedControlItem(FDIALOG_OPENCHOICES,&choice);
		if(SUCCEEDED(hr)) {
			if(choice==FDIALOG_CHOICE_REPARENT) {
				pFInfoList->uiCmdOpts = CMD_REPARENT;
			}
            else if(choice==FDIALOG_CHOICE_ALLHASHES) {
                pFInfoList->uiCmdOpts = CMD_ALLHASHES;
            }
            else if(choice==FDIALOG_CHOICE_BSD) {
                pFInfoList->uiCmdOpts = CMD_FORCE_BSD;
            }
		}

		pfdc->Release();
	}

	return S_OK;
}
开发者ID:KagamiChan,项目名称:RapidCRC-Unicode,代码行数:56,代码来源:COpenFileListener.cpp

示例15: qt_win_CID_get_existing_directory

QString qt_win_CID_get_existing_directory(const QFileDialogArgs &args)
{
    QString result;
    QDialog modal_widget;
    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
    modal_widget.setParent(args.parent, Qt::Window);
    QApplicationPrivate::enterModal(&modal_widget);

    IFileOpenDialog *pfd = 0;
    HRESULT hr = CoCreateInstance(QT_CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,
                                  QT_IID_IFileOpenDialog, reinterpret_cast<void**>(&pfd));

    if (SUCCEEDED(hr)) {
        qt_win_set_IFileDialogOptions(pfd, args.selection,
                                      args.directory, args.caption,
                                      QStringList(), QFileDialog::ExistingFile,
                                      args.options);

        // Set the FOS_PICKFOLDERS flag
        DWORD newOptions;
        hr = pfd->GetOptions(&newOptions);
        newOptions |= (FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM);
        if (SUCCEEDED(hr) && SUCCEEDED((hr = pfd->SetOptions(newOptions)))) {
            QWidget *parentWindow = args.parent;
            if (parentWindow)
                parentWindow = parentWindow->window();
            else
                parentWindow = QApplication::activeWindow();

            // Show the file dialog.
            hr = pfd->Show(parentWindow ? parentWindow->winId() : 0);
            if (SUCCEEDED(hr)) {
                // Retrieve the result
                IShellItem *psi = 0;
                hr = pfd->GetResult(&psi);
                if (SUCCEEDED(hr)) {
                    // Retrieve the file name from shell item.
                    wchar_t *pszPath;
                    hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
                    if (SUCCEEDED(hr)) {
                        result = QString::fromWCharArray(pszPath);
                        CoTaskMemFree(pszPath);
                    }
                    psi->Release(); // Free the current item.
                }
            }
        }
    }
    QApplicationPrivate::leaveModal(&modal_widget);

    qt_win_eatMouseMove();

    if (pfd)
        pfd->Release();
    return result;
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:56,代码来源:qfiledialog_win.cpp


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