Solved

Retrieve full path of file from IStream instance

Posted on 2012-04-02
2
997 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

832 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