title: Finding preview handler GUIDs for image types (gif, bmp, jpg, etc)
body: <p>If you use windows explorer and click on an item like a .docx or a .jpg file you get a preview of the item you clicked on within the explorer <a href="https://i.stack.imgur.com/BPcf4.png" rel="nofollow noreferrer">like this</a>.  I'm trying to replicate this within my windows form application and it works fine for .docx and .xlsx files but it doesn't for image file types. 
  To my understanding preview handlers are registered under the GUID {8895b1c6-b41f-4c1c-a562-0d564250836f} in filextension/ShellEx. Using regedit you can see that .docx files have these <a href="https://i.stack.imgur.com/1XElw.png" rel="nofollow noreferrer">.docx previewhandler GUID</a>, but when you look at something like .jpg there is nothing to be found. (<strong>i.stack.imgur.com/40v6h.png</strong>). (I'm not allowed to post more than 2 links)</p>
  
  <p>According to the first answer to this post (<strong>stackoverflow.com/questions/39373357/how-to-get-the-icon-path-and-index-associated-with-a-file-type</strong>) there are other locations the preview handler might be stored in for a .jpg, but they all show up empty for me. </p>
  
  <p>My question: How do I get the preview handlers for the extension types windows can find but I can't. I think there are preview handlers stored somewhere but I don't know where they are or how to reach them. </p>
  
  <p>This is the code I use to get the GUIDs of files. Succesfull for type .docx and .xlsx but not for image types. I go past every location mentioned in the last link but they all turn up null.</p>
  
  <pre><code>    private Guid GetPreviewHandlerGUID(string filename)
      {
          // open the registry key corresponding to the file extension
          string extention = Path.GetExtension(filename);
          RegistryKey ext = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64);
  
          // open the key that indicates the GUID of the preview handler type
          string className = Convert.ToString(ext.GetValue(null));
          RegistryKey test = ext.OpenSubKey(className + "\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
          if (test != null) return new Guid(Convert.ToString(test.GetValue(null)));
          // sometimes preview handlers are declared on key for the class
          if (className != null) {
                  test = ext.OpenSubKey(extention + "\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
              if (test == null)
                  test = ext.OpenSubKey("SystemFileAssociations\\" + className + "\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
              if (test == null)
                  test = ext.OpenSubKey("SystemFileAssociations\\" + extention + "\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
              if (test == null)
                  test = ext.OpenSubKey("SystemFileAssociations\\image\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
              if (test != null) return new Guid(Convert.ToString(test.GetValue(null)));
          }
  
          return Guid.Empty;
      }
  </code></pre>
  
  <p>This is my first post here so I hope I was informative enough. If there are things missing I'll add them when I get a chance. Thank you.</p>