How do I display the Find Printers dialog programmatically?

A customer wanted to display the Find Printers dialog programmatically to let the user pick a printer from Active Directory and wanted to know whether this was possible.

Yes, it's possible, and there's more than one way to do it. There's the lazy way and the overachieving way.

The overachieving way is to use the ICommon­Query::Open­Query­Window method. The Find­AD­Printers sample function spells it all out for you.

The lazy way takes a little bit of out-of-the-box thinking: Open the Find Printers dialog, set up the search the way you want it, and then save the search to a file (File, Save Search). In your program, when you need to open the Find Printers dialog, just Shell­Execute the saved search.

Comments (6)
  1. henke37 says:

    There sure is a lot of things that you can open just by opening a saved search.

  2. Ivo says:

    I found the simplest way is to just call IShellDispatch2::FindPrinter –…/bb774134(v=vs.85).aspx

    BTW, I've never used OpenQueryWindow, but it seems an added benefit of using it is that the code gets back the selected printer. With ShellExecute or FindPrinter you don't get that.

  3. Kemp says:

    > There sure is a lot of things that you can open just by opening a saved search.

    What do you want to do tonight Brain?

    The same thing we do every night Pinky – try to open the saved search that takes over the world…

  4. Worf says:

    Hrm, that saved search thing sounds cool, but why do I get the impression I'm going to see it on thedailywtf in the near future?

  5. xilun says:

    This doesn't feel lazy at all. This feels smart. This feels the way software should be designed to avoid being bloated.

  6. mvadu says:

    @Raymond, about the lazy way, what if some one used this way from Xp (or 95 era) and tries to run it now? Since .fnd is no longer supported will it still work?

Comments are closed.