The default verb is not necessarily "open"

If you hunt around the Internet you'll find lots of people† who hard-code the string "open" as the second parameter to the ShellExecute function, indicating that they want to open the document specified as the third parameter. While that's a nice thing to want to do, it might not be the right thing.

When the user double-clicks a document, the shell executes the default verb, which is not necessarily "open". For example, for audio files, the default verb is often "play", and for pictures, it's often "view". If you want to launch the document as if the user had double-clicked it, then you need to pass NULL as the lpOperation.

OK, but why have "play" or "view" in place of "open"? Why not just have "open"? It means the same thing. What’s the semantic different between opening a word document, opening a PDF, opening an image, opening a movie, and opening a sound recording?

Why pick a non-"standard" verb to do something when the standard one would work just as well?

Responding to Adam and expanding on what S wrote, "play" and "view" are, of course, more descriptive than "open"; and "open" is ambiguous. ("Open" for what purpose? To edit? To play or view?)

This seems like enough justification to use a "non-standard verb"–because the standard verb won’t work just as well.

As a generally corollary: "Why do X when Y would be just as good?" is a common question, often used (as in this case) to claim that doing X was a mistake. But it is often the case (as it is here) that the correct answer to the question is, rather, "Y would not be just as good." When you observe someone doing something that you don’t understand, it’s possible that they do know what they’re doing.

The reason the default action isn’t always ‘Open’ is because that’s not very clear to the user. For images, I see ‘Preview’ and ‘Edit’. I haven’t a clue which the ‘Open’ verb is connected to, actually.

And with .reg files, the default action is Merge. I’m not sure what the Open command does, but it’s quite likely to open (for editing) in Notepad rather than merging the .reg file. Not a good user experience if their program opens a file with a bunch of registry keys for them to look at!

By the way, is there any way for me to tell what Open does in Vista? Other than checking the registry, of course. I just don’t see advanced application association anymore…

it’s not necessarily just a question of semantics (where "open" really means "play", all of the time). HTML docs you might want to open/view (in a browser), or open/edit (in Notepad, etc.). Batch files you might want to run, or, if you’re like me, you change the default action to opening them in Notepad.

Why do any of you care what the default verb is called when you can execute it by not giving a verb?

Or, put another way, there already is a default verb: NULL.

Seems to me that everyone wants ShellExecute to work in the incorrect way they’ve been using it (so that "open" always executes the default action) instead of changing the way they are using it to the correct method (passing NULL for the verb if you want the default).

Very good point, Weiguo. Users should be free to change which verb is the default — to change what happens when they double-click files — without having to change the meanings of the verbs themselves, since that could break other programs which legitimately call a specific verb.

Thank you (mostly) for the nitpicker’s corner. Even though your anger is apparent, the meaning behind it really does help (mostly). Just please keep in mind that in many cases your readers have more reasons for anger than you do. Please recall

“Why do any of you care what the default verb is called when you can execute it by not giving a verb?”

Because the default can be changed. For instance, out of the
box, I believe the default action for a .html file is “open”, whereas
on my machine it’s “edit”. I find it particularly annoying when a
program then produces an HTML report and launches it in my text editor,
because it should have been written to use the “open” action which is
guaranteed to do what it wants. [1] Programs _should_ be hard coding
what action to perform on the file if there is a particular action that
should be performed, rather than just a nebulous “do whatever the user
normally wants to do with this type of file” concept.

[1]: This is, however, a step better than the programs which launch
IE despite the fact I have HTML files ‘open’ action associated with
Firefox.

[I find it interesting that you actually want a program to override your custom default action. -Raymond]

Hardcoding it to "open" still doesn’t ensure that it will always open in a web browser. On one of my machines, "open" on HTML files results in the file opening in VIM. This is probably a more common situation than "edit" being the default action, as windows makes it easier to change file associations than default actions. If you want a file to always open in a certain type of program, you have to hardcode in the program to be run, which causes all the problems with IE opening when you wanted FF.

You can change the default verb so that you can register associations for "shared" file types to your application without conflicting with the existing ones. Except a file type in Windows is really meant as a "document type", i.e. the data for a specific application, and not a "content type", so what the usual offenders (see: media players, office suites) often do is just pointing the extension to a different filetype altogether

Funny thing is, urlmon does add all the code and registry data to link document types to content types (among which even a database of content type signatures, or "magic numbers"), but it’s only used by Internet Explorer, not by the shell except indirectly when opening content through an URL, so it might as well not be there at all

People might say Internet Explorer is too integrated with the shell, I say it isn’t integrated enough, not when an URL scheme needs to be registered in three different places to actually work everywhere (why not register URL handlers as regular monikers, instead of the HKCRPROTOCOLS, mk: URL scheme etc. mess?)

I guess Apple did handle this kind of mess better with Uniform Type Identifiers