Thread: IShellFolder

  1. #1
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895

    IShellFolder *resolved*

    How do I get an IShellFolder for a given folder name? I tried this:

    Code:
    	IShellFolder *pDesktop;
    	HRESULT hr = SHGetDesktopFolder(&pDesktop);
    	if(FAILED(hr))
    		throw hresult_exception(hr);
    
    	LPITEMIDLIST piil;
    	OLECHAR *pDir = new OLECHAR[dir.size()];
    	wcscpy(pDir, dir.c_str());
    	hr = pDesktop->ParseDisplayName(0, 0, pDir, 0, &piil, 0);
    	delete[] pDir;
    	if(FAILED(hr))
    		throw hresult_exception(hr);
    
    	IShellFolder *pMine;
    	hr = pDesktop->BindToObject(piil, 0, IID_IShellFolder, (void **)&pMine);
    	pMalloc->Free(piil);
    	if(FAILED(hr))
    		throw hresult_exception(hr);
    dir is a std::wstring.
    The debugger shows the contents of dir as "G:\download\temp", which should be correct.

    However, ParseDisplayName returns E_FAIL.
    Does anyone know the reason? I need this for a nice tool that lets you apply a regular expression replace to each filename in a folder (great when downloading or ripping music).

    Thanks in advance
    CornedBee
    Last edited by CornedBee; 05-13-2003 at 09:47 AM.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Never mind, I called the app incorrectly.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed