Select a Folder using VC++

Posted: July 17, 2009 in Programming Tips, VC++, Visual Studio, Windows, XP
Tags: , , ,

To select a folder use the following code snippet where you want.

BROWSEINFO stBrowseInfo;
LPITEMIDLIST lpSelectedPid;
TCHAR pszSelectedFolder[MAX_PATH];

stBrowseInfo.hwndOwner          = m_hWnd;
stBrowseInfo.pidlRoot           = NULL;
stBrowseInfo.pszDisplayName     = pszSelectedFolder;
stBrowseInfo.lpszTitle          = _T( "Select Your Folder" );
stBrowseInfo.ulFlags            = BIF_RETURNONLYFSDIRS ;
stBrowseInfo.lpfn               = NULL;
stBrowseInfo.lParam             = 0;
lpSelectedPid                   = SHBrowseForFolder( &stBrowseInfo );

SHGetPathFromIDList( lpSelectedPid, pszSelectedFolder );
m_csFolderName                  = pszSelectedFolder;
UpdateData( FALSE );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s