title: IFileDialog / IShellItem::GetDisplayName doesn't work with Windows 7 libraries
body: <pre><code>IFileDialog *pfd;
  ...
  CoCreateInstance(CLSID_FileOpenDialog,NULL,
     CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&amp;pfd));
  ...
  IShellItem *psiResult;
  pfd-&gt;GetResult(&amp;psiResult);
  ...
  wchar_t *filepath;
  psiResult-&gt;GetDisplayName(SIGDN_FILESYSPATH,&amp;filepath);
  ...
  </code></pre>
  
  <p>This works perfectly well for regular files but fails (E_INVALIDARG) when the file is fetched via a Windows 7 library folder (the same file will work when accessed via it's normal path). The <a href="http://msdn.microsoft.com/en-us/library/bb762544%28VS.85%29.aspxE" rel="nofollow">doc</a> says that :</p>
  
  <blockquote>
    <p>SIGDN_FILESYSPATH (Returns the item's
    file system path, if it has one. Only
    items that report SFGAO_FILESYSTEM
    have a file system path. <strong>When an item
    does not have a file system path, a
    call to IShellItem::GetDisplayName on
    that item will fail</strong>. In UI this name
    is suitable for display to the user in
    some cases, but note that it might not
    be specified for all items.</p>
  </blockquote>
  
  <p>But using SIGDN_NORMALDISPLAY or all others SIGDN Enumeration fails too.</p>
  
  <p>So how to get full path when the file is fetched via a Windows 7 libraries ?</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I can get the folder via :</p>
  
  <pre><code>IShellItem *psiResult;
  pfd-&gt;GetFolder(&amp; psiResult); 
  LPWSTR folderpath = NULL; 
  psiResult-&gt;GetDisplayName(SIGDN_FILESYSPATH, &amp; folderpath); 
  </code></pre>
  
  <p>But GetDisplayName() doesn't work with pfd->GetResult(&amp; psiResult); </p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I found what was not working, it was in CoInitializeEx. I used COINIT_MULTITHREADED, if I change it to COINIT_APARTMENTTHREADED it then works.</p>