<!-- Link to demo file download -->
<!-- Add the rest of your HTML here -->
If you've ever had to look up a Knowledge Base article using its number, you know that the process it a bit
tedious. First browse to msdn.microsoft.com, enter the article number in
the tiny search edit box, wait for the search results to come back, and then finally click the link to the article.
There isn't a quick way to jump right to an article, until now!
KBLaunch is a shell extension that extends the Run dialog. Simply enter
?q followed by the article
number, as pictured here:
When you hit Enter, KBLaunch runs your default browser and points it right at the web page for the article.
How It Works
KBLaunch registers itself as a shell execute hook. Shell execute hooks are called in two cases:
- Whenever a program is run with
ShellExecuteEx(). This includes
double-clicking on a file in Explorer.
- Whenever the user enters something in the Run dialog.
What's interesting about hooking the Run dialog is that we can let the user enter something that isn't a program
name, but which instructs our extension to do something. Internet Explorer is a good example of this - if you enter
a URL (starting with
www, or other common prefixes), the shell
execute hook provided by IE interprets that and launches the browser.
KBLaunch looks for the prefix
?q, and then reads the rest of the command line. If it is a positive
number, KBLaunch constructs the URL for the article and runs your default browser with
passing it that URL. Note that this makes use of IE's own shell execute hook (described above) to launch the web
browser, so you'll need IE 3 or later installed.
A shell execute hook extension is almost trivial - there's only one interface to implement, and that interface
only has one method. The method is
IShellExecuteHook::Execute(), and it receives a pointer to a
struct which holds a bunch of info about the program being run.
Execute() handles parsing the command
line and running the browser, as described above. The code for this is in the
in the sample project.