DllPreviewHandler for Windows Vista

At DevConnections this week, I wanted to demonstrate how easy it can be to write preview handlers for Windows Vista.  Using the framework I created for my article in the January 2007 issue of MSDN Magazine, I whipped up this little guy:

    [PreviewHandler(“MSDN Magazine DLL Preview Handler”, “.dll”, “{1A565B60-5BEA-463d-9413-9F201320A2BB}”)]
public sealed class DllPreviewHandler : FileBasedPreviewHandler
protected override PreviewHandlerControl CreatePreviewHandlerControl()
return new DllPreviewHandlerControl();

private sealed class DllPreviewHandlerControl : FileBasedPreviewHandlerControl
public override void Load(FileInfo file)
TextBox text = new TextBox();
text.ReadOnly = true;
text.BackColor = SystemColors.Window;
text.ScrollBars = ScrollBars.Vertical;
text.Multiline = true;
text.Dock = DockStyle.Fill;

ProcessStartInfo psi = new ProcessStartInfo(
@”C:\program files\Microsoft SDKs\Windows\v6.0\VC\Bin\dumpbin.exe”,
“/summary /exports \”” + file.FullName + “\””);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;

using (Process p = Process.Start(psi))
text.Text = p.StandardOutput.ReadToEnd();


The preview handler displays the results of running dumpbin.exe on the selected DLL, showing all of the exports from the DLL.  If you do a lot of P/Invoke work, something like this can come in very handy when browsing a directory of DLLs.  To accomplish this, it simply creates a TextBox, spawns a process to run dumpbin, and stuffs the output from dumpbin into the TextBox.

Note that for this to compile and work, you’ll need to reference the DLL provided along with the magazine article.  Once you install it, you’ll get nice views like this:

On your system, you may need to change the path to dumpbin.exe, which I’ve hardcoded here for simplicity of example. YMMV.

Comments (9)

  1. Mark says:

    Wow, that is amazingly simple.  This is a good thing.  I think we will see some very creative uses of this as Vista matures.  

    Is it just as simple to add thumbnail handlers?

  2. Mark, glad you like it! 🙂  Regarding thumbnail providers, while it is possible to write them in .NET, it’s not recommended.  See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=125283&SiteID=1 for more information.

  3. J.Marsch says:


    I’ve read elsewhere: http://blogs.msdn.com/oldnewthing/archive/2006/12/18/1317290.aspx

    that we should not write shell extensions in managed code.  (because it injects a .net runtime version dependency into the shell, and therefore into any application that uses the shell, even when displaying file open/save dialogs).

    Does this advice not apply to Vista?

  4. J, please see my article on preview handlers at http://msdn.microsoft.com/msdnmag/issues/07/01/PreviewHandlers/, specifically the section entitled "Hosting a Preview Handler".  That should answer your question.

  5. Indra says:


    Is it possible to display the preview in our own application instead of using the explorer??

  6. Dan says:


    Is it possible to use Preview Handler within a .Net application rather than accessing explorer to do the preview (aka the new quick preview in Leopard)?

    I believe it would be better if it just simply launched a new window showing the preview of the selected file because with the preview pane enabled, it takes up too much desktop estate.

  7. rpowers says:

    It is possible to "host" previews in a managed application.

    I just finished some work for the Visual Studio Express team with help from Stephen to build a control and sample of leveraging his managed preview handler framework and displaying the preview results within a .net winform.

    The work was part of a bigger project called the coding4fun Developer Kit 2008.  You can get it <a href=http://www.codeplex.com/c4fdevkit>here</a&gt;.  Also I wrote a blog describing the preview handler host <a href=http://blogs.claritycon.com/blogs/ryan_powers/archive/2007/07/26/3245.aspx>here</a&gt;.

    Thanks to Stephen for his help and for building the core framework.

  8. Sreedhar says:

    Hi Steve,

    I was wondering, if you have come across a solution/utility that would convert audio from WMV files (recorded from live meeting sessions) into a transcript file?

    Any insight would be appreciated.


  9. Hou says:

    Is this also available for XP OS?