Capturing files in a directory
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 23

Thread: Capturing files in a directory

Threaded View

  1. #16
    Join Date
    Mar 2011
    Posts
    144

    Re: Capturing files in a directory

    Ok thanks, is this ok to do? Also, why is it that I'm only calling dir.push_back once, yet I have 2 elements? The first is empty, the 2nd is my push_back call.

    Code:
    			TCHAR SomeArray[_MAX_PATH];
    			buttonPush(hWnd,dir);
    			_tcscpy(SomeArray, dir[1].c_str());
    			SetWindowText(textBox2, SomeArray);
    Code:
    bool buttonPush(HWND hWnd, StringVector &dir ) {
    
    		BROWSEINFO bi;
       TCHAR szDir[MAX_PATH];
       LPITEMIDLIST pidl;
       LPMALLOC pMalloc;
    
       if (SUCCEEDED(SHGetMalloc(&pMalloc)))
       {
          ZeroMemory(&bi,sizeof(bi));
          bi.hwndOwner = hWnd;
          bi.pszDisplayName = 0;
          bi.pidlRoot = 0;
          bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
    	  bi.pszDisplayName = szDir; // Address of a buffer to receive the display name of the folder selected by the user
    		bi.lpszTitle = _T("Select a folder"); // Title of the dialog
    
          bi.lpfn = BrowseCallbackProc;
    	pidl = SHBrowseForFolder(&bi); 
    		
    		if (pidl) 
    		{ 
    			TCHAR SomeArray[_MAX_PATH];
    			BOOL bRet = ::SHGetPathFromIDList(pidl, SomeArray);
    			dir.push_back(SomeArray);
    			pMalloc->Free(pidl); 
    			pMalloc->Release();
    			if(bRet) return true;
    		} 
        }
       return false;
    }
    Last edited by drwbns; January 10th, 2013 at 01:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center