[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Retrieve full path of file from IStream instance

Posted on 2012-04-02
2
Medium Priority
?
1,070 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

656 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