Solved

Retrieve full path of file from IStream instance

Posted on 2012-04-02
2
1,004 Views
Last Modified: 2012-04-06
Hi I am implementing a thumbnail provider for my custom files. So I have implemented 2 interfaces IThumbnailProvider and IInitializeWithStream interface. I have over written the methods Initialize() of IInitializeWithStream and GetThumbnail() of IThumbnailProvider .

Initialize() and GetThumbnail() methods are invoked when user open a directory in Windows Explorer which consists of my custom files.

In Initialize(), I get an instance to IStream object. Over here i am able to retrieve just the file name. is there any way through which i can retrieve Full path of the file.

I have tried using IStream_ReadPidl() but some how it fails. it doesnt return S_OK. It returns 0x8007000D.



I am using Visual Studio 2010. And working on a Windows 7 OS.

Regards
0
Comment
Question by:RsTVS
  • 2
2 Comments
 

Author Comment

by:RsTVS
ID: 37795552
I have tried using IStream_ReadPidl() but some how it fails. it doesnt return S_OK
0
 

Accepted Solution

by:
RsTVS earned 0 total points
ID: 37815222
Got the full path of the file using a different method.
Get the explorer handle first.
Check the handle of Addressbar of Windows Explorer with SPY++ and i went down the windows hierarchy and got the folder path. Check the code below and you will get the full folder path.

  HWND l_pExplorerhwnd = ::GetForegroundWindow();
  TCHAR l_szTempName[MAX_PATH];

  if(l_pExplorerhwnd)
  {
    HWND hwnd = ::FindWindowEx(l_pExplorerhwnd, NULL, L"WorkerW", NULL);
    if(hwnd)
    {
      hwnd = ::FindWindowEx(hwnd, NULL, L"ReBarWindow32", NULL);
      if(hwnd)
      {
        hwnd = ::FindWindowEx(hwnd, NULL, L"Address Band Root", NULL);
        if(hwnd)
        {
          hwnd = ::FindWindowEx(hwnd, NULL, L"msctls_progress32", NULL);
          if(hwnd)
          {
            hwnd = ::FindWindowEx(hwnd, NULL, L"Breadcrumb Parent", NULL);
            if(hwnd)
            {
              hwnd = ::FindWindowEx(hwnd, NULL, L"ToolbarWindow32", NULL);
              if(hwnd)
                ::InternalGetWindowText (hwnd, l_szTempName, MAX_PATH);
              else
                return E_FAIL;
            }
            else
              return E_FAIL;
          }
          else
            return E_FAIL;
        }
        else
          return E_FAIL;
      }
      else
        return E_FAIL;
    }
    else
      return E_FAIL;
  }
  else
    return E_FAIL;

Open in new window


Retrieve the file name from IStream interfaces stat function and append it to the folder path.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 116
Bot application - advice 3 38
what is the best Integrated development environment 2 21
convert Systemjs to Webpack 3 34
A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question