Solved

Retrieve full path of file from IStream instance

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issues with C++ Class 19 81
iframe detection of parent window scale 20 60
Full Screen problem when auto scale IFRAME 2 65
Auto-indent certain lines in Notepad++ 10 31
A short article about a problem I had getting the GPS LocationListener working.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 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

13 Experts available now in Live!

Get 1:1 Help Now