Solved

Retrieve full path of file from IStream instance

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now