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


C++ SHBrowseForFolder函数代码示例

本文整理汇总了C++中SHBrowseForFolder函数的典型用法代码示例。如果您正苦于以下问题:C++ SHBrowseForFolder函数的具体用法?C++ SHBrowseForFolder怎么用?C++ SHBrowseForFolder使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: fileSelectPath

BOOL fileSelectPath(HWND HWindow,PSTR szTitle,PSTR szPath)
{
  BOOL         retCode;
  LPMALLOC	   pMalloc;
  BROWSEINFO   nBI;
  LPITEMIDLIST pidl;
  
  memset(&nBI,0,sizeof(nBI));
  nBI.hwndOwner      = HWindow;
  nBI.pszDisplayName = szPath;
  nBI.lpszTitle      = szTitle;
  nBI.ulFlags        = BIF_RETURNONLYFSDIRS | BIF_BROWSEFORCOMPUTER;
  if (NULL == (pidl=SHBrowseForFolder(&nBI))) return FALSE;
  retCode = SHGetPathFromIDList(pidl,szPath);
  SHGetMalloc(&pMalloc);
  pMalloc->lpVtbl->Free(pMalloc,pidl);
  pMalloc->lpVtbl->Release(pMalloc);
  return retCode;
}
开发者ID:cirosantilli,项目名称:netWork-fork,代码行数:19,代码来源:fileLib.c

示例2: SHBrowseForFolder

// private
void ILaunchDialog::choose_client_dir()
{
	char path[MAX_PATH + 1];
	BROWSEINFO bi;

	bi.hwndOwner = m_hwnd;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = path;	// This is just for display: not useful
	bi.lpszTitle = "Choose Client Directory";
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	bi.lpfn = NULL;
	bi.lParam = 0;
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
	if(pidl != NULL && SHGetPathFromIDList(pidl, path))
	{
		m_config.set_client_dir(path);
		SetDlgItemText(m_hwnd, ID_ST_CLIENTDIR, path);
	}
}
开发者ID:byterj,项目名称:Injection_0.3.30.2,代码行数:20,代码来源:ilaunch.cpp

示例3: ZeroMemory

/*****************************************************************
** 函数名:GetPath
** 输 入: 无
** 输 出: CString strPath
**        strPath非空, 表示用户选择的文件夹路径
**        strPath为空, 表示用户点击了“取消”键,取消选择
** 功能描述:显示“选择文件夹”对话框,让用户选择文件夹 结果:如:"E:\xxx个人文件夹\plc"
****************************************************************/
CString CUtil::getPath(HWND hwndOwner)
{
	CString strPath =_T("");
	BROWSEINFO bInfo;
	ZeroMemory(&bInfo, sizeof(bInfo));
	bInfo.hwndOwner = hwndOwner;
	bInfo.lpszTitle = _T("请选择路径: ");
	bInfo.ulFlags = BIF_RETURNONLYFSDIRS;    

	LPITEMIDLIST lpDlist; //用来保存返回信息的IDList
	lpDlist = SHBrowseForFolder(&bInfo) ; //显示选择对话框
	if(lpDlist != NULL)  //用户按了确定按钮
	{
		TCHAR chPath[255]; //用来存储路径的字符串
		SHGetPathFromIDList(lpDlist, chPath);//把项目标识列表转化成字符串
		strPath = chPath; //将TCHAR类型的字符串转换为CString类型的字符串
	}
	return strPath;
}
开发者ID:iloveghq,项目名称:GaborPC,代码行数:27,代码来源:Util.cpp

示例4: UpdateData

void CDjvuDlg::OnButton2() 
{
	BROWSEINFO bi= {m_hWnd, NULL, NULL, "Please, choose the folder...",
					BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_BROWSEFORCOMPUTER,
					NULL, NULL, 0};
		
	LPCITEMIDLIST lpItemDList;
	if(!(lpItemDList=SHBrowseForFolder(&bi)))
	{
	}
	else
	{
		char buff[200];
		SHGetPathFromIDList(lpItemDList, buff); // 
		OutputDir=buff; UpdateData(DlgSet);
	}	
	
	
}
开发者ID:mar80nik,项目名称:djvu,代码行数:19,代码来源:djvuDlg.cpp

示例5: SHBrowseForFolder

void CTabSample::OnBnClickedButtonSavefilepath()
{
	// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
	// 文件夹选择对话框

	char szDir[MAX_PATH];

	BROWSEINFO bi;

	ITEMIDLIST *pidl;

	bi.hwndOwner = this->m_hWnd; // 指定父窗口,在对话框显示期间,父窗口将被禁用 


	bi.pidlRoot = NULL; // 如果指定NULL,就以“桌面”为根 

	bi.pszDisplayName = szDir; 

	bi.lpszTitle = "请选择采样数据存储目录"; // 这一行将显示在对话框的顶端 

	bi.ulFlags = BIF_STATUSTEXT | BIF_USENEWUI | BIF_RETURNONLYFSDIRS;

	bi.lpfn = NULL;

	bi.lParam = 0;

	bi.iImage = 0;

	pidl = SHBrowseForFolder(&bi);

	if(pidl == NULL) 
	{
		return;
	}
	if(!SHGetPathFromIDList(pidl, szDir))
	{	
		return;
	}
	else
	{
		m_csSaveFilePath = szDir;
	}
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:43,代码来源:TabSample.cpp

示例6: _T

void CCopyDlg::OnBrowse() 
{
    TCHAR folder[MAX_PATH];
    BROWSEINFO bi;
    bi.hwndOwner = m_hWnd;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = folder;
    bi.lpszTitle = _T("Select folder to install into");
    bi.ulFlags = 0;
    bi.lpfn = NULL;
    bi.lParam = NULL;
    bi.iImage = 0;
    ITEMIDLIST *id = SHBrowseForFolder(&bi);
    if (id == NULL) // cancelled
        return;
    SHGetPathFromIDList(id, folder);
    m_Target.Format(_T("%s"), folder);
    UpdateData(FALSE);
}
开发者ID:melbcat,项目名称:DynamoRIO-for-ARM,代码行数:19,代码来源:CopyDlg.cpp

示例7: SHBrowseForFolder

void ConfigDlg::OnPath() 
{
    
    BROWSEINFO bi = {0};
    bi.hwndOwner = m_hWnd;
    bi.lpfn = BrowseCallbackProc;
    bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_EDITBOX ;
    LPITEMIDLIST pIt= SHBrowseForFolder( &bi );
    if( pIt )
    {
        // Set the new path as the selected folder and refresh
        TCHAR tcPath[ MAX_PATH ];
        if( SHGetPathFromIDList( pIt, tcPath ))
        {
            m_List.InsertItem( 0, tcPath );
            m_bChanged = true;
        }
    }
}
开发者ID:hladrien,项目名称:leakmon,代码行数:19,代码来源:ConfigDlg.cpp

示例8: SHBrowseForFolder

// 选择文件存储路径
void CSaveFile::OnSelectSaveFilePath(void)
{
	char szDir[MAX_PATH];

	BROWSEINFO bi;

	ITEMIDLIST *pidl;

	bi.hwndOwner = m_hWnd; // 指定父窗口,在对话框显示期间,父窗口将被禁用 


	bi.pidlRoot = NULL; // 如果指定NULL,就以“桌面”为根 

	bi.pszDisplayName = szDir; 

	bi.lpszTitle = "请选择数据存储目录"; // 这一行将显示在对话框的顶端 

	bi.ulFlags = BIF_STATUSTEXT | BIF_USENEWUI | BIF_RETURNONLYFSDIRS;

	bi.lpfn = NULL;

	bi.lParam = 0;

	bi.iImage = 0;

	pidl = SHBrowseForFolder(&bi);

	if(pidl == NULL) 
	{
		return;
	}
	if(!SHGetPathFromIDList(pidl, szDir))
	{	
		return;
	}
	else
	{
		m_csSaveFilePath = szDir;
	}
	pidl = NULL;
	delete pidl;
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:43,代码来源:SaveFile.cpp

示例9: ZeroMemory

void BrowseFolderMenuItem::onSelect()
{
	if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
	{
		DropDownMenu* dropDownMenu = dynamic_cast<DropDownMenu*>(getParent());
		if (dropDownMenu)
		{
			BROWSEINFO browseInfo;
			ZeroMemory(&browseInfo, sizeof(browseInfo));
			browseInfo.hwndOwner = winOS->GetWindowsHandle();
			browseInfo.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
			PIDLIST_ABSOLUTE pidl = SHBrowseForFolder(&browseInfo);
			if (pidl)
			{	
				if (winOS->GetLibraryManager())
				{
					QSharedPointer<Library> library = winOS->GetLibraryManager()->addFolderAsLibrary(pidl);
					if (library)
					{
						LOG(QString("Library Directory: %1\n").arg(library->getFolderPaths().front()));
						
						// Save the newly created library
						QList<QString> otherLibs = winOS->GetLibraryManager()->getFolderLibraryDirectories();
						GLOBAL(settings).otherLibraries = otherLibs;
						winOS->SaveSettingsFile();
						
						LibraryMenuItem* item = new LibraryMenuItem(library);
						dropDownMenu->select(item);
						SwitchToLibrary(library);
					}
				}
				CoTaskMemFree(pidl);
			}
			else
			{
				// Reselect the last selected object, since this selection failed
				dropDownMenu->select(dropDownMenu->items().front());
			}
		}
		CoUninitialize();
	}
}
开发者ID:DX94,项目名称:BumpTop,代码行数:42,代码来源:BT_LibraryOverlay.cpp

示例10: strncpy

char *askcdstring(const char *question, const char *default_str)
{
    LPMALLOC g_pMalloc;
    BROWSEINFO bi;
    LPITEMIDLIST pidlBrowse;
    browserInfo info;
    OSVERSIONINFOEX osvi;

    strncpy(info.question, question, 40);
    strncpy(info.default_str, default_str, MAX_PATH);

    /* Get the shell's allocator. */
    if (!SUCCEEDED(SHGetMalloc(&g_pMalloc))) return NULL;

    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    GetVersionEx((OSVERSIONINFO *)&osvi);

    ZeroMemory(&bi, sizeof(bi));
    bi.hwndOwner = 0;
    if(osvi.dwMajorVersion >= 6) { /* future proof */
	/* CSIDL_DESKTOP gets mapped to the User's desktop in Vista
	   (a bug).  SHGetFolderLocation is Win2k or later */
	if (!SUCCEEDED(SHGetFolderLocation(NULL, CSIDL_DRIVES, NULL, 0,
					   (LPITEMIDLIST *) &bi.pidlRoot)))
	    return NULL;
    }  /* else it is 0, which is CSIDL_DESKTOP */
    bi.pszDisplayName = strbuf;
    bi.lpszTitle = question;
    bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
    bi.lpfn = (BFFCALLBACK) InitBrowseCallbackProc;
    bi.lParam = (LPARAM) &info;

    /* Browse for a folder and return its PIDL. */
    pidlBrowse = SHBrowseForFolder(&bi);
    if (pidlBrowse != NULL) {
	SHGetPathFromIDList(pidlBrowse, strbuf);
	g_pMalloc->lpVtbl->Free(g_pMalloc, pidlBrowse);
	if (strbuf[0])
	    return strbuf;
    }
    return NULL;
}
开发者ID:Chaos1989,项目名称:r-source,代码行数:42,代码来源:dialogs.c

示例11: SelectDirectoryDlg

/*!
	ディレクトリ選択ダイアログの表示
	@param[in]	hWnd		親ウインドウのハンドル
	@param[in]	ptSelFolder	ディレクトリ名を入れるバッファへのポインター
	@param[in]	cchLen		バッファの文字数。バイト数じゃないぞ
	@return		非0:ディレクトリとった 0:キャンセルした
*/
BOOLEAN SelectDirectoryDlg( HWND hWnd, LPTSTR ptSelFolder, UINT_PTR cchLen )
{
	BROWSEINFO		stBrowseInfo;
	LPITEMIDLIST	pstItemIDList;
	TCHAR	atDisplayName[MAX_PATH];

	if( !(ptSelFolder) )	return FALSE;
	ZeroMemory( ptSelFolder, sizeof(TCHAR) * cchLen );

	//	BROWSEINFO構造体に値を設定
	stBrowseInfo.hwndOwner		 = hWnd;	//	ダイアログの親ウインドウのハンドル
	stBrowseInfo.pidlRoot		 = NULL;	//	ルートディレクトリを示すITEMIDLISTのポインタ・NULLの場合デスクトップ
	stBrowseInfo.pszDisplayName	 = atDisplayName;	//	選択されたディレクトリ名を受け取るバッファのポインタ
	stBrowseInfo.lpszTitle		 = TEXT("AAの入ってるディレクトリを選択するのー!");	//	ツリービューの上部に表示される文字列
	stBrowseInfo.ulFlags		 = BIF_RETURNONLYFSDIRS;	//	表示されるディレクトリの種類を示すフラグ
	stBrowseInfo.lpfn			 = NULL;		//	BrowseCallbackProc関数のポインタ
	stBrowseInfo.lParam			 = (LPARAM)0;	//	コールバック関数に渡す値

	//	ディレクトリ選択ダイアログを表示
	pstItemIDList = SHBrowseForFolder( &stBrowseInfo );
	if( !(pstItemIDList) )
	{
		//	戻り値がNULLの場合、ディレクトリが選択されずにダイアログが閉じられたということ
		return FALSE;
	}
	else
	{
		//	ItemIDListをパス名に変換
		if( !SHGetPathFromIDList( pstItemIDList, atDisplayName ) )
		{
			//	エラー処理
			return FALSE;
		}
		//	atDisplayNameに選択されたディレクトリのパスが入ってる
		StringCchCopy( ptSelFolder, cchLen, atDisplayName );

		//	pstItemIDListを開放せしめる
		CoTaskMemFree( pstItemIDList );
	}

	return TRUE;
}
开发者ID:16in,项目名称:OrinrinEditor,代码行数:49,代码来源:OrinrinViewer.cpp

示例12: switch

INT CALLBACK LoggingPage::dialogProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch ( msg )
	{
		case WM_COMMAND:
		{
			if ( HIWORD(wParam)==EN_CHANGE )
			{
				if ( IsWindowVisible(hWnd) ) {
					SendMessage(GetParent(hWnd),UWM_SETTINGS_CHANGED,NULL,NULL);
				}
			}

			switch ( wParam )
			{
				case IDC_BUTTON_BROWSE:
				{
					char path[MAX_PATH] = {0};

					BROWSEINFO bi = {0};
					bi.hwndOwner = hWnd;
					
					LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
					if ( pidl!=NULL ) {
						SHGetPathFromIDList(pidl,path);
						SetWindowText(m_hEditPath,path);
					}

					IMalloc *pMalloc = NULL;
					if ( SUCCEEDED(SHGetMalloc(&pMalloc)) ) {
						pMalloc->Free(pidl);
						pMalloc->Release();
					}
				}
				break;
			}
		}
		break;
	}

	return 0;
}
开发者ID:CIHANGIRCAN,项目名称:vibestreamer,代码行数:42,代码来源:LoggingPage.cpp

示例13: SHGetDesktopFolder

void CXMLDialog::GetPath(CString& strPath, CString strTitle)
{
	LPITEMIDLIST lpItemList = NULL;
	LPSHELLFOLDER pDesktopFolder;
	if (!strPath.IsEmpty())
	{
		OLECHAR chOlePath[255];
		ULONG   pchEaten;
		ULONG   dwAttributes;

		HRESULT hr = SHGetDesktopFolder(&pDesktopFolder);
		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strPath.GetBuffer(MAX_PATH), -1,
	                         chOlePath, MAX_PATH);
		strPath.ReleaseBuffer (-1);

		hr = pDesktopFolder->ParseDisplayName(NULL,
                                            NULL,
                                            chOlePath,
                                            &pchEaten,
                                            &lpItemList,
                                            &dwAttributes);
	}

	BROWSEINFO binfo;
	binfo.hwndOwner = NULL;
	binfo.pidlRoot = lpItemList; //NULL;
	binfo.pszDisplayName = NULL;
	binfo.lpszTitle = (LPCTSTR)strTitle;
	binfo.ulFlags = BIF_RETURNONLYFSDIRS|BIF_RETURNFSANCESTORS|BIF_NONEWFOLDERBUTTON;
	binfo.lpfn = NULL;
	binfo.lParam = 0;
	binfo.iImage = 0;

	LPITEMIDLIST pItemID = SHBrowseForFolder(&binfo);	
	if (!pItemID)
		return;

	TCHAR szPath[MAX_PATH];
	*szPath = _T('\0');
	SHGetPathFromIDList(pItemID, szPath);
	strPath = szPath;
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:42,代码来源:XMLDialog.cpp

示例14: SelectFolder

WStringAutoPtr SelectFolder ( WStringAutoPtr prompt )
{
	BROWSEINFO browse_info = { 0 };
	browse_info.hwndOwner = GetActiveWindow();
	browse_info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
    browse_info.lpszTitle = prompt->c_str();

    LPITEMIDLIST item_list = SHBrowseForFolder ( &browse_info );
	
	// if the user hasn't cancelled the dialog get the path to the folder

    wchar_t path[MAX_PATH] = L"";

	if ( item_list != 0 ) {
		SHGetPathFromIDList ( item_list, path );
	}

	return WStringAutoPtr ( new wstring ( path ) );

}	//	SelectFolder
开发者ID:n9yty,项目名称:BaseElements-Plugin,代码行数:20,代码来源:BEWinFunctions.cpp

示例15: BrowseDir

BOOL CFileUtil::BrowseDir(CDuiString &path,HWND hwndOwner,CDuiString title)
{
	TCHAR szPathName[MAX_PATH]; 
	BROWSEINFO bInfo={0};  
	bInfo.hwndOwner=hwndOwner;//父窗口  
	bInfo.lpszTitle=title;  
	bInfo.ulFlags=BIF_RETURNONLYFSDIRS |BIF_USENEWUI/*包含一个编辑框 用户可以手动填写路径 对话框可以调整大小之类的..*/|  
		BIF_UAHINT/*带TIPS提示*/ |BIF_NONEWFOLDERBUTTON /*不带新建文件夹按钮*/;  
	LPITEMIDLIST lpDlist;  
	lpDlist=SHBrowseForFolder(&bInfo);  
	if (lpDlist!=NULL)//单击了确定按钮  
	{  
		SHGetPathFromIDList(lpDlist,szPathName); 
		path.Format(_T("%s"),szPathName);  
		return TRUE;
	}else
	{
		return FALSE;
	}
}
开发者ID:boyisgood86,项目名称:Redrain-,代码行数:20,代码来源:FileUtil.cpp


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