IShellFolder

This is a discussion on IShellFolder within the Windows Programming forums, part of the Platform Specific Boards category; How do I get an IShellFolder for a given folder name? I tried this: Code: IShellFolder *pDesktop; HRESULT hr = ...

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

    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,893
    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

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