Directory Selection

This is a discussion on Directory Selection within the C++ Programming forums, part of the General Programming Boards category; Hi there!! How can I display a window in which I can select a directory, which path I can use ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    Directory Selection

    Hi there!!


    How can I display a window in which I can select a directory, which path I can use afterwards?
    I made it once before,but now I just can't find it!!!


    Thx
    Han

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Assuming you're talking about Windows, try here.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    directory dialog

    In windows the following function will display the directory box and return the directory selected as a CString.

    Code:
    CString GetFolderPath()
    {
    	CoInitialize(0);
    
    	char szDirectory[1024];
    	HRESULT hr;
    	BROWSEINFO browseInfo;
    	LPITEMIDLIST lpItemList=0;
    
    	LPMALLOC lpM;
    	hr = SHGetMalloc (&lpM) ;
    	if (FAILED(hr) ) return _T("");
    
    	ZeroMemory ( (PVOID) &browseInfo,sizeof (BROWSEINFO));
      
      	browseInfo.pidlRoot = 0;
    	browseInfo.hwndOwner = NULL;
    	browseInfo.pszDisplayName = szDirectory;
    	browseInfo.lpszTitle = "Open Folder ";
    	browseInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS;
    	browseInfo.lParam = 0;
    
    	if ((lpItemList = SHBrowseForFolder(&browseInfo)) == NULL)
    	{
    		return _T("");
    	}
    
    	SHGetPathFromIDList(lpItemList,szDirectory); 
    
    	lpM->Free(lpItemList);
    	lpM->Release();
    
    
    	CString strPath;
    
    	strPath = _T(szDirectory);
    
    
    	return strPath;	
    }
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2008, 09:02 AM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 01:54 AM
  4. Replies: 6
    Last Post: 07-30-2003, 03:08 AM
  5. Directory reading trouble
    By samGwilliam in forum Linux Programming
    Replies: 0
    Last Post: 03-10-2002, 08:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21